Hello,
I am having problem to figure it out... I think it is more a shell problem than a IM one.
I have a directory with PNG, png, JPEG, JPG, jpg, GIF, gif... images. And I want to thumbnail all theses images in png format.
Today I use :
mogrify -path thumbs2x -thumbnail 50x50 -background transparent -gravity center -extent 50x50 *.png
but it only takes png files... I tried *.[png|jpg|...] but it fails.
Do you have ideas ??
Thansk for your help
K.
Pass all kind of image file in a single request
Re: Pass all kind of image file in a single request
Lateral thinking is probably required!
I use php and would read the whole directory using glob and the image names would then be in an array. I would then loop through the array feeding the image name to the comand via a variable.
I use php and would read the whole directory using glob and the image names would then be in an array. I would then loop through the array feeding the image name to the comand via a variable.
-
- Posts: 88
- Joined: 2010-06-29T14:36:09-07:00
- Authentication code: 8675308
Re: Pass all kind of image file in a single request
I suppose the idea is to "create" new thumbnails for each image ...
so an aproach would be:
convert * -thumbnail 50x50 -background transparent -gravity center -extent 50x50 *_thumb.png
If and only if all the files present in the dir are images ( or at least if convert can read them as images) ...
Greetings
so an aproach would be:
convert * -thumbnail 50x50 -background transparent -gravity center -extent 50x50 *_thumb.png
If and only if all the files present in the dir are images ( or at least if convert can read them as images) ...
Greetings
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Pass all kind of image file in a single request
One way is (don't forget to tell mogrify the desired output format using -format png). Note you cannot change the output name. I think you are mistaking the input and output parts of mogrify. Read this in more detail http://www.imagemagick.org/Usage/basics/#mogrify
mogrify -path thumbs2x -format png -thumbnail 50x50 -background transparent -gravity center -extent 50x50 *
another is to write a script that just changes the input format
mogrify -path thumbs2x -format png -thumbnail 50x50 -background transparent -gravity center -extent 50x50 *.png
mogrify -path thumbs2x -format png -thumbnail 50x50 -background transparent -gravity center -extent 50x50 *.jpg
etc for each input format
Just on a whim, I tried this simple test and it worked:
mogrify -path /Users/fred/test2 -format png *.png *.gif *.jpg *.GIF
Again on a whim, I tried to change the output name as follows, but it has limitations of adding a period:
mogrify -path /Users/fred/test2 -format thumb.png *.png *.gif *.jpg *.GIF
results in names like
tree.jpg ---> tree.thumb.png
mogrify -path thumbs2x -format png -thumbnail 50x50 -background transparent -gravity center -extent 50x50 *
another is to write a script that just changes the input format
mogrify -path thumbs2x -format png -thumbnail 50x50 -background transparent -gravity center -extent 50x50 *.png
mogrify -path thumbs2x -format png -thumbnail 50x50 -background transparent -gravity center -extent 50x50 *.jpg
etc for each input format
Just on a whim, I tried this simple test and it worked:
mogrify -path /Users/fred/test2 -format png *.png *.gif *.jpg *.GIF
Again on a whim, I tried to change the output name as follows, but it has limitations of adding a period:
mogrify -path /Users/fred/test2 -format thumb.png *.png *.gif *.jpg *.GIF
results in names like
tree.jpg ---> tree.thumb.png
Re: Pass all kind of image file in a single request
Solved !
I don't do it with the correct approach (learn, fail, learn, fail, ask, learn, succeed). But I am in a hurry for this part of my project.
Thanks a lot for your help !
The result is :
$format_img_double = 50x50
mogrify -path thumbs2x -thumbnail $format_img_double -format png -background transparent -gravity center -extent $format_img_double toCompute/*.*
The *.* permit to avoid errors on directories
The toCompute/ only contains img
I purge thumbs2x with rm+mkdir at start of script
I use mogrify because I want to keep the same filenames !
Thanks
I don't do it with the correct approach (learn, fail, learn, fail, ask, learn, succeed). But I am in a hurry for this part of my project.
Thanks a lot for your help !
The result is :
$format_img_double = 50x50
mogrify -path thumbs2x -thumbnail $format_img_double -format png -background transparent -gravity center -extent $format_img_double toCompute/*.*
The *.* permit to avoid errors on directories
The toCompute/ only contains img
I purge thumbs2x with rm+mkdir at start of script
I use mogrify because I want to keep the same filenames !
Thanks
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Pass all kind of image file in a single request
that is a shell problem. If you are using BASH shell you can specify files in many ways.kheraud wrote:but it only takes png files... I tried *.[png|jpg|...] but it fails.
One method is {xxx,yyy,zzz}
so try... *.{png,jpg,gif}
NOTE this will expand without sorting to *.png *.jpg *.gif so it will do all PNG images first.
an alturnative is to generate a list of filename...
ls *.{png,jpg,gif} | mogrify ..... @-
Ls will sort all the files alphabetically itself. The @- reads a list of filenames from '-' or standard input. See the last part of the section...
http://www.imagemagick.org/Usage/files/#read
if you are trying to avoid directories...
find * -prune -type f | ....
See http://www.imagemagick.org/Usage/basics/#mogrify-not
You will also probably be interested in the section before that
which uses a technique of using convert instead of mogrify
http://www.imagemagick.org/Usage/basics ... fy_convert
Its very useful is combined with the "xargs" or "parellel" comamnds.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/