Re: Image scaling problem
On Fri, Jun 23, 2000 at 12:19:52PM -0400, "Rider, Todd M. (LNG)" <[EMAIL PROTECTED]> wrote: > I would like to use gimp to programmatically reduce thousands of images. > > Can I link in a gimp library and call some functions to do the scaling from Not in the 1.x versions of gimp, i.e. not at all in the moment. > a C++ program? If not can I do this in a batch mode, from the command line? You might need to write a script. > Is gimp the right tool for this, are there alternatives? Are you aware of ImageMagick: $ mogrify -geometry 50% *.jpg This would scale all jpg files to 50% of their original size, supposedly with the superiour result than gimp. -- -==- | ==-- _ | ---==---(_)__ __ __ Marc Lehmann +-- --==---/ / _ \/ // /\ \/ / [EMAIL PROTECTED] |e| -=/_/_//_/\_,_/ /_/\_\ XX11-RIPE --+ The choice of a GNU generation | |
Re: Image scaling problem
The gimp currently is a sub-optimal program for batch processing. If you're really talking thousands of pics, look elsewhere. There should be some good stand-alone C/C++ libraries for image processing--I imagine that those coming with the Gimp are rather specialized. However, at the bottom of this message is included a bash script for scaling *.bmp images with Gimp 1.1.23. Batch scripting with the Gimp is currently rather slow because the program reloads for each picture. I have some ideas for getting around this (i.e. 1 BIG instruction line, some other possibilities) but am leaving them for later or someone else. [whichever comes first ;-)] The script should be easily modified to work with all image types. Basically, you should only have to change the gimp-file-save instruction. To start, play with #'s in the range 0-10 where the 2 currently is. Have fun, Daniel Herring [EMAIL PROTECTED] P.S> Many thanks to Alan Buxey for getting me headed down the right scripting path. Following is the script. Make sure the line starting with "gimp -n" and ending with "\" is restored to 1 line. _ #!/usr/bin/bash #Edit this first line to show the directory to your shell environment #You can get this from issuing the command `echo $SHELL` or `which bash` ... #NOTE: If this script gives a "permission denied" error, did you issue `chmod 755 scaleFilter.sh`? # Are you calling it as `./scaleFilter.sh` in the directory containing the images to be changed? #Constants --don't edit FALSE=0 TRUE=1 # #Edit these variables as needed files=`ls *.bmp` # modify to change different images backup=$FALSE # $TRUE or $FALSE --do you want a backup? backupDIR=orig # name of backup directory --use a plain . for current directory scale=2 # scalar multiplier for the image (newWidth=width*scale...) must be greater than 0 #Don't edit past here. # path=`pwd` for file in $files do echo "Processing $file" # Backup? if [ $backup -eq $TRUE ] then if test -e $backupDIR then cp $file $backupDIR/$file else echo "Making backup directory" mkdir $backupDIR cp $file $backupDIR/$file fi fi gimp -n --verbose -b "(begin (set! theImage (car (gimp-file-load 1 \"$path/$file\" \"$file\")))(set! height (* $scale (car (gimp-image-height theImage(set! width (* $scale (car (gimp-image-width theImage(gimp-image-scale theImage height width)(set! theDrawable (gimp-image-active-drawable theImage))(gimp-file-save 1 theImage 2 \"$path/$file\" \"$file\"))" \ '(gimp-quit 1)' done #Script released under the GPL on 6-19-2000 by Daniel Herring ([EMAIL PROTECTED]) #This script works with the Gimp version 1.1.23 #It will not work under version 1.0.4 without some editing (I think)
Re: Image scaling problem
"Rider, Todd M. (LNG)" <[EMAIL PROTECTED]> writes: > Is gimp the right tool for this, are there alternatives? No, I think ImageMagick would be the better tool for such a job, have a look at mogrify which is included in ImageMagick. There is also a C++ librarie called libMagick++ from where you can access ImageMagik, but I never tested it... -- ICQ: 59461927http://pingus.seul.org | Ingo Ruhnke <[EMAIL PROTECTED]> http://home.pages.de/~grumbel/ | '
Image scaling problem
I would like to use gimp to programmatically reduce thousands of images. Can I link in a gimp library and call some functions to do the scaling from a C++ program? If not can I do this in a batch mode, from the command line? Is gimp the right tool for this, are there alternatives? Thanks, Todd