I am using ImageMagick convert command for making thumbnails & save the converted images in another directory, one by one, in PHP.
But, cant figure out how to keep the the image name in the converted image.
> convert 1.JPG -resize 120X120 thumb/*.JPG
need to keep the output file names same as the input. Please help.
Yes it is purely an alias for xc: which stood for "X window color", which came from the extreme early days of ImageMagick (long before my time). Of course color is usually a SVN color rather than X window color, so really the original name is rather useless.
Left-clicking on an image brings up a simple, standalone menu (the only GUI feature you'll see in ImageMagick).
Another way:
convert *.jpg -resize 80% -set filename:f '%t' ../'%[filename:f].jpg'
Will place converted files in the folder above.
The option -set filename:f '%t'
sets the property filename:f
to the current filename without the extension. Properties beginning with filename:
are a special case that can be referenced in the output filename. Here we set it to ../'%[filename:f].jpg
, which ends up being the image filename with the extension replaced with .jpg
in the parent directory.
-set
documentation, which mentions the filename:
special case%t
and other Format and Print Image PropertiesA simple solution would be copy, followed by mogrify - another imagemagick tool - this will keep the same names, it takes all the same args as convert.
cp *.jpg thumb/ cd thumb mogrify -resize 120X120 *.JPG
Alternatively you could do a bit of shell scripting, using find -exec or xargs
# using -exec find . -iname "*.JPG" -maxdepth 1 -exec convert -resize 120x120 {} thumbs/{} \; # using xargs find . -iname "*.JPG" -maxdepth 1 | xargs -i{} convert -resize 120x120 {} thumbs/{}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With