Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Image format converter

 
Post new topic   Reply to topic Printable version
 View previous topic  [PHP] Colored SVN Diffs Post :: Post Official Team Tracker Forum  View next topic  
Author Message
grazzhoppa
Novice


Joined: Jan 03 2007
Posts: 29
Offline

PostPosted: Thu Aug 02, 2007 7:02 pm    Post subject: Image format converter Reply to topic Reply with quote

Requires/Uses Microsoft .NET framework 2.0 or 3.0. I think 2.0 will work ok with it.

Handy for selecting all those 3MB .bmp screenshots and making them into .png while deleting the bmp ones, in a few clicks.



written in C#, requires Visual Studio 2005 to compile. Source/project files/windows form included with the program's .exe

http://forums.minegoboom.com/files/ImageSaver.zip

It eats up 20-30MB of ram - the downside of using .NET.

Limitations of this program:
It does not save/carry over any EXIF data for jpegs. My concern with this is someone using this program to convert jpegs created with their digital camera and losing all the good info digital cameras put into jpeg images.

I don't know if the .ico format conversion is useful. Aren't .ico files supposed to have multiple images of different resolutions within the .ico file? This program only puts one image into the .ico file.

The png encoder the program uses is not "the best". I think it is equivalent to saving png files with MS Paint. I mean that it will not generate the smallest png files possible.
Use the pngcrush.exe, included in the .zip, and the "Use pngcrush" option to send this program's .png files through pngcrush's better algorithms. It'll result in a lower .png file size without quality loss. Thanks to minegoboom for showing me pngcrush.

The jpg encoder is not very good. I think it's the same one that MS Paint uses.

If you choose to not "Replace images with the new format", and try converting an image to the same format as the original image, AND you have a file in the same directory as the image, with COPY to the end of the file name, this program will overwrite that COPY file. See the following example to understand this easier.

Example: "image.jpg" and "imageCOPY.jpg" are in the same folder. You select "image.jpg" and convert it to jpg without "Replace images with the new format" checked. Your "imageCOPY.jpg" is overwritten by a file that this program generates.

edit:
Running png files through pngcrush or optipng

optipng is packaged up with it, so you can use it to compress png files better than Microsoft's .NET png encoder.
You can either have "optipng.exe" in the same folder as the ImageSaver.exe, or specify the file path to pngcrush.exe executable as the first command line parameter of ImageSaver.exe.

Optipng and pngcrush will do the same thing - shrink the .png file size without color loss. you can use either one by having the executable named "optipng.exe" or "pngcrush.exe" in the same directory as this program.
OR you can specify the location of the pngcrush program via the 1st command line parameter of this program. You cannot specify the location of optipng via the command line.

I just recommend keeping "optipng.exe" in the same folder as this program, and you'll be all set.
But if you want to use pngcrush and you don't want to have it in the same folder as this program:
You can specify the command line argument via a shortcut.

Put the full path to the pngcrush .exe in quotes.
The text in the "Target" box needs to be something like this:
Code: Show/Hide
C:\windows_programming\ImageSaver\bin\Release\ImageSaver.exe "C:\The Folder Path To\This Is Pngcrush.exe"




ImageSaver.zip - 128.36 KB
File downloaded or viewed 13 time(s)

command_line.PNG - 11.22 KB
File downloaded or viewed 2 time(s)

imagesaver.png - 24.79 KB
File downloaded or viewed 3 time(s)


Last edited by grazzhoppa on Sat Aug 11, 2007 8:19 pm, edited 12 times in total
Back to top
View users profile Send private message Add User to Ignore List
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Fri Aug 03, 2007 8:49 pm    Post subject: Reply to topic Reply with quote

What's that slider do in the top right? Were you just experimenting with the different controls? "Get Files" doesn't even look like a button. (I didn't try the program yet).
_________________
ss news
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:35
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3604
Location: Las Vegas
Offline

PostPosted: Fri Aug 03, 2007 9:26 pm    Post subject: Reply to topic Reply with quote

Running your image through pngcrush resulted in a 33% decrease in file size. I'm pretty sure you can choose a better optimization level for your png output.
Back to top
View users profile Send private message Add User to Ignore List Send email
grazzhoppa
Novice


Joined: Jan 03 2007
Posts: 29
Offline

PostPosted: Sat Aug 04, 2007 10:10 am    Post subject: Reply to topic Reply with quote

The slider in the top right sets the window's opacity. It goes from 90 to 100% opaque.

This whole program was an experiment with controls.

The "Get Files" button is flat styled and pops up when you put the mouse over it.

You can also drag files from Windows Explorer onto the white list box rather that use the "Get Files" button.

---

The program uses the image encoders that come with the .NET framework. The encoders get the job done, but aren't flexible:

The .gif encoder can only do 8 bit gifs - and it doesn't work on animated gifs.
The png encoder can only do 24/32 bit pngs, and it only has one algorithm.
The bmp encoder can only do 24 bit bmps.

This program fakes 8 bit bmps by converting the image to an 8bit gif, then converting that 8bit gif into a bmp.
It also offers the option of doing that for png's, which reduces the amount of colors in the image and subsequently the png file size.

I appreciate you showing me pngcrush.
I added an option to use pngcrush or optipng when converting to png, and I included the optipng.exe with this program. Check the original post for an updated.zip.

This option also works when you have .png files selected, and you are "converting" to png - it'll use pngcrush or optipng which will attempt to reduce the png's filesize.

By the way, if you are "converting" from one image format to the same image format, this program will make a copy of the original image and append "COPY" to the file name.

So if you want to run a lot of png files through pngcrush/optipng, make sure you have "Replace Images with the new format" checked or you'll end up with the original images and lots of COPYs.
Back to top
View users profile Send private message Add User to Ignore List
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:35
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3604
Location: Las Vegas
Offline

PostPosted: Sat Aug 04, 2007 4:33 pm    Post subject: Reply to topic Reply with quote

grazzhoppa wrote:
I appreciate you showing me pngcrush.
I added an option to use pngcrush or optipng when converting to png, and I included the optipng.exe with this program. Check the original post for an updated.zip.

If you plan on using external programs, give ImageMagick a try. Can do any image manipulation you want from a command line interface.
Back to top
View users profile Send private message Add User to Ignore List Send email
tcsoccerman
Server Help Squatter


Age:26
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Sat Aug 04, 2007 10:23 pm    Post subject: Reply to topic Reply with quote

I'm a c# coder as wel, and my most recent project is a simple photo organizer and viewer. mind if i add to you're program with my coding and ideas?
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
grazzhoppa
Novice


Joined: Jan 03 2007
Posts: 29
Offline

PostPosted: Sun Aug 05, 2007 9:48 am    Post subject: Reply to topic Reply with quote

Go ahead, if you can put up with wading through the code

If you're just looking for how to convert image formats, read how to do it here
http://www.codeproject.com/cs/media/imagconvert.asp

It boils down to this:
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap("Path to the image file");
bitmap.Save("Path/image name to save to", System.Drawing.Imaging.ImageFormat.xxxx);

That's what this program does. All the other code is for handling the gui aspect of it.
You might be better off making your own Form and gui.
Back to top
View users profile Send private message Add User to Ignore List
BDwinsAlt
Agurus's Posse


Age:28
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Mon Aug 06, 2007 3:36 pm    Post subject: Reply to topic Reply with quote

Mono doesn't like your program.
Code: Show/Hide

brad@brad-laptop:~/Desktop/net$ mono ImageSaver.exe

** (ImageSaver.exe:6672): WARNING **: The following assembly referenced from /home/brad/Desktop/net/ImageSaver.exe could not be loaded:
     Assembly:   System.Windows.Forms    (assemblyref_index=1)
     Version:    2.0.0.0
     Public Key: b77a5c561934e089
The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (/home/brad/Desktop/net/).


** (ImageSaver.exe:6672): WARNING **: Could not load file or assembly 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.

** (ImageSaver.exe:6672): WARNING **: Missing method EnableVisualStyles in assembly /home/brad/Desktop/net/ImageSaver.exe, type System.Windows.Forms.Application

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.


Would you happen to know a way to tweak this to work for everyone? It's just something small in the GUI.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
D1st0rt
Miss Directed Wannabe


Age:31
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Mon Aug 06, 2007 6:16 pm    Post subject: Reply to topic Reply with quote

Here are the results from when I ran it through MoMA, if you can try changing your code to avoid using those methods it should work
_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
grazzhoppa
Novice


Joined: Jan 03 2007
Posts: 29
Offline

PostPosted: Mon Aug 06, 2007 9:15 pm    Post subject: Reply to topic Reply with quote

Updated Form1.cs and Form1.Designer.cs that fixes the problems in the MoMA report:
http://forums.minegoboom.com/files/monoImageSaver.zip
But you need to find an alternative for setting the System.Windows.Forms.PictureBox.ImageLocation property, or else the picture preview functionality won't work.

If running on non-Windows OS, and you want to use this program with optipng/pncrush, you'll need to change all strings "optipng.exe" and "pngcrush.exe" to the appropriate file extensions for your OS.


According to d1's Mono report...
Deal breakers:
---------------
Line 470 of Form1.cs
this.pictPreview.ImageLocation = (string)this.lstFiles.SelectedItem

That tells the PictureBox control to use the file path, which is selected in the ListBox control, as the location of the image to display. You can get rid of this line, but the image preview functionality will be completely broken.
If you find the property of the PictureBox control that allows setting the location of the image to display, then replace "this.pictPreview.ImageLocation = " with it.
---------------
Line 507 of Form1.cs
this.pictPreview.ImageLocation = "";

Same deal as above. But... you can delete this line without any functionality lost - this line just clears the picture preview so that no image is displayed. When you delete this, the picture preview will just display a picture that isn't in the ListBox anymore.
--------------
If you're running on non-Windows OS:

It starts at Line 105 of Form1.cs.

There's code to start an external process "explorer.exe" with "/select,"path to a file"" command line argument. This will need to be written specifically for whatever file manager/viewer you desire using. You'll probably get error pop ups from your OS about not finding "explorer.exe" when this code is invoked.

It could just be removed, as it's not critical to the program - it's a convenience feature.
It's meant to open up Windows Explorer when you right click a file name in the ListBox.

Also in that area of code, it prints out "Windows Explorer launched", so you may want to change that text.
---------

Fixed:

All System.ComponentModel.Win32Exception are changed to System.Exception to make sure it catches exceptions on a non-Windows OS.

ToolStrip.set_AllowItemReorder(bool)
I erased this, as the functionality that it provides wasn't even being used by this program.

ToolTip.set_IsBalloon
and
ToolTip.set_ToolTipIcon
are erased. They are Windows only eye-candy for tooltips.

All of the Control.set_AutoSize(bool) are erased. They weren't necessary. They increased the size of the controls based on the text within them - this functionality wasn't being used in this program.

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
Is erased.
That tells Windows to scale the font size with the screen resolution - not necessary and I don't even know if it works nicely with the GUI.




monoImageSaver.zip - 13.43 KB
File downloaded or viewed 2 time(s)
Back to top
View users profile Send private message Add User to Ignore List
D1st0rt
Miss Directed Wannabe


Age:31
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Mon Aug 06, 2007 10:10 pm    Post subject: Reply to topic Reply with quote

You should be able to do something along the lines of
Code: Show/Hide
#if !Mono
    //put windows only code in here
#endif


then when building it for use in mono you pass /define:Mono to the compiler and it won't include anything in those blocks
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
tcsoccerman
Server Help Squatter


Age:26
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Sat Aug 11, 2007 2:18 pm    Post subject: Reply to topic Reply with quote

grazzhoppa here's my start. all this program does so far is have a main folder named "mydocuments/mypictures/photohutphotos/" that then has folders in the main folder which resemble "photolists" with photos in those folders with the photolists photos. all photos are sput into the main folder which resembles the "allphotos" photolists. this gets converted to a tree list view in the program. i'm having problesm with working with the files, so since you seem to be a good programmer if you could help me on getting delete access to delete the folders when they delete the photolists, that would be great.

p.s. if you click "convert images" in tools it has you're nifty converter. i hope to make this a project among the subspace c# developers. also, please post you're attachments if they are updated. good luck, and thank you.




The sharpdevelop project folder. objs/debug/photohut.exe for program. has bugs though, and will crash if you try deleting.

Photo Hut.zip - 126.59 KB
File downloaded or viewed 3 time(s)
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Non-Subspace Related Coding All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 94 page(s) served in previous 5 minutes.

phpBB Created this page in 0.108121 seconds : 38 queries executed (50.7%): GZIP compression disabled