You are here

[server side] more than hundred thousand images to resample

Hi there,
I'd like to investigate the power of gimp on the server side,
this is the problem:

mogrify (imagemagick) does not satisfy my needs, I find that creating avatars with it does not provide the best results.

I have about ~600k avatars to resample and a lot of cpu power
the servers are running debian and my proposal is to find the avatar > 20kb (100x100 px)
and downsize the jpg quality to 80.

the problem is that I've read some documentation but couldn't find a way to achieve this.

can anyone give me some good tips?

(if there's any way to have a coder doing this I'd be glad to pay for it)

regards

It seems doable. You can run gimp non-interactive. This link discusses a script in the scheme language (.scm) that in a batch, opens files and resaves them in jpeg. http://lists.xcf.berkeley.edu/lists/gimp-user/2006-June/008172.html About selecting the large files: you might modify this script, or you might write a shell script to do the selecting. About setting the jpeg compression. It seems like Gimp defaults to 85, but maybe if it opens a jpeg file, it retains the quality when it saves it, so you might have to modify the script. I think the architecture of Gimp is that all the file saving is done by extensions, callable from scripts and I would guess they are parameterizable. I tested saving to jpg, Gimp opens a dialog to set the quality, again, I would hope that non-interactive, you could pass that parameter. Me, I don't know the Scheme language well enough and would opt for Python, which is very much a scripting language with full access to the OS. So from within the script you would invoke Gimp once, filter the large files, load and save. I'm not an expert at Gimp or Python, dangerous. plashless, off banks of noon

You might investigate the Dave's Batch Processor plug-in (http://members.ozemail.com.au/~hodsond/dbp.html), though I am not sure if it has limitations on number of files. An alternative solution would be to use a shell script to find all candidates for resizing and to move them to a common location (this would probably be necessary even if the DBP plug-in is used), while renaming them employing a sequential numbering scheme; and retaining the information about their original name and location. To avoid problems with differing filetypes, I would recommend converting them to PNG format during this step. (This will also ensure that the JPEG quality gets lowered; GIMP sometimes attempts to be "smart" about not lowering the quality during saves, though I don't know if this is handled by the user interface or the JPEG save plug-in itself.) Once you have all the files in a single directory -- and named something like 'file_000001.png', 'file_000002.png', 'file_000003.png', ... -- you can use the GIMP's GAP plug-in to convert them to JPEGs of a specified quality (the Convert command in the "Video" menu). After the files have been converted, you would restore the files to their original location (they should end up named with a JPEG extension). Again, this would be handled by a relatively simple shell script which fetches the filenames from a text file created when the files were originally renamed.
Subscribe to Comments for "[server side] more than hundred thousand images to resample"