Shrinking large images

BlitzMax Forums/BlitzMax Programming/Shrinking large images

Mordax_Praetorian(Posted 2009) [#1]
I recently joined a company that needs to step into the online market in order to survive, however in order to get the site working as it needs to, we clearly need images of each product we sell

This leaves me with thousends of high quality images from our manufacturers to process, and the company doesn't have the several months I'd need to process them all manually, so I turned to Blitz in order to make a batch processing solution

The problem I'm having is with ResizePixmap(), the loss of quality from taking an image that is Several-Thousend*Several-Thousend down to 100x100 directly gives a loss of quality that leaves the images unusable, areas of the image that look a flat grey on the high quality version can become a blurred mass of differently coloured pixels

Is there a blitz in-code method of making a large image (initially jpeg) much smaller without making it look like crap?

It doesn't need to be fast, we can leave the program running over several days if need be


Brucey(Posted 2009) [#2]
What about using a module which supports proper scaling of images?

FreeImage scales nicely, and is also quite fast.


Volker(Posted 2009) [#3]
Yes, you should take a look at brucey's freeimage mod.
Should do everything you need.
http://maxmods.googlecode.com/files/freeimage_1_04_src.zip


Mordax_Praetorian(Posted 2009) [#4]
Ok, I got the module and I'm reading through the docs for it now

I'll owe you a huge debt of gratitude if this works Brucey


Warpy(Posted 2009) [#5]
Can I suggest you use irfanview instead of spending time writing your own tool?


Brucey(Posted 2009) [#6]
Where's the fun in that?


xlsior(Posted 2009) [#7]
Outside of Blitz you can also do batch conversions of images with ImageMagick or nconvert (command line component for XNView)

(Brucey also has an ImageMagick module available)


Mordax_Praetorian(Posted 2009) [#8]
The problem with existing tools is that the files also require batch renaming, reorganising, overlay of other images and conditional duplication based on data about products and features read from a .csv file

this fact means that no existing tool is going to be able to work to the exact conditions we need, and, apart from resizing, all of that can be sorted with about a hundred lines of Blitz

Edit: oh, and it doesn't look like ifranview can save to .png, which is needed to combine small size with perfect colour information and transparency


iprice(Posted 2009) [#9]
Silly question but how on earth is it even remotely possible to turn thousands of images "Several-Thousend*Several-Thousend "pixels into images 100x100 and them not to be crap - especially if the process is automated?

Seems like someone is asking for the impossible in just a short space of time.


Digital Anime(Posted 2009) [#10]
Agree @ iprice.

100x100 isn't much and it will either look a little blurry or more pixely depending on how your application downscales.

Best is to look at the 100x100 pictures when they are shown at 100% size. Also don't look at the pictures using the Windows standard picture viewer to look at it, it uses blur for everything.

I remember with Paint Shop Pro 6 downscaled pictures looked very good for some reason. It doesn't look that good with Paint Shop Pro 9 I'm using today, but that might be a setting.


ImaginaryHuman(Posted 2009) [#11]
The reason that resize pixmap makes it a mess is because it does absolutely no filtering, it does a `nearest neighbor` pixel selection rather than averaging the pixels.

You could try loading the picture as an Image with the FILTEREDIMAGE flag, and then use SetScale to scale it down to the right size, and then DrawImage to draw it with hardware filtering, and then GrabPixmap.


Gabriel(Posted 2009) [#12]
I would have done it the same way as ImaginaryHuman. Hardware texture filtering ought to be decent enough, and it's going to be pretty fast and easy to boot.