Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
thousands of images (directory)
to minimal size without loss of quality or resolution
what extension, code plz...
Posted
Updated 31-Aug-14 13:43pm
v2
Comments
[no name] 31-Aug-14 19:45pm    
You would need to either write the code yourself or hire someone to write it for you. We do not write code to order here. You can go to a site like www.vworker.com to hire someone to write code for you.
john1990_1 31-Aug-14 19:47pm    
it's just something like that

foreach(Fileinfo fi in directory)
{
fi.Save(@"G:\newFolder\fi.Name");
}

what is the best extension for images, that's all i'm asking, a 3 line code...
[no name] 31-Aug-14 20:07pm    
Oh well then that's easy. Since the file extension has pretty much nothing to do with anything, use whatever file extension you want.
john1990_1 31-Aug-14 20:38pm    
do pics lose quality or resolution when saved as png files?
is png the best when it comes to size?
[no name] 31-Aug-14 21:06pm    
What does that have to do with your question? png is a lossless file format so quality should not be too bad. "best" is irrelevant. Size is going to depend on what you are doing. I would suggest that you learn how to do some research. If you think that you just have to change a file extension to "png" and some magical process converts the file to a png image, you are in for a rude shock.

1 solution

This question does not make much sense, because "extensions" means nothing. First, in fact, there are no file "extension". They were in obsolete file systems, but now the word "extension" is still used, but in a difference sense, just as a part of file name, and is still used to denote "file type". It does not affect any functionality pe se. Secondly, "extension" only suggests some file type, but say little or nothing about actual content. For example, *.TIFF means TIFF container which can use no compression, lossy or lossless compression of different types. So, just forget about "extension". It's probably that you need some lossless algorithm, by I cannot be sure that you really need it, taking into account that with lossy algorithm you can get much smaller size without noticeable loss in visible quality.

Also, "resolution", in contrast to common belief, has nothing to do with the size of the image in pixel. Moreover, resolution, being a part of metadata does not affect the view of the image on screen, not at all. This is just the suggested default which can be used, for example, to print the image to "default" size in sm or inches.

It's not clear what "to minimal size" may mean. If you mean size of the image file in bytes, it should apparent, that you can reduce the size due to lossless compression, but not much. It's very important to understand that the "near-optimal" algorithm really depends on each individual image: for one, one algorithm with some set of parameters can be used, with different image, a different algorithm and parameter set can be better. You can experiment with different methods and choose the one which gives you better results, perhaps on image-to-image basis.

Please see:
http://en.wikipedia.org/wiki/Lossless_compression[^],
http://en.wikipedia.org/wiki/Data_compression[^],
http://en.wikipedia.org/wiki/Lossy_compression[^],
http://en.wikipedia.org/wiki/Data_compression[^].

You can experiment with the algorithms listed in the articles referenced above.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900