Problem with convert -resize

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
stin
Posts: 4
Joined: 2012-05-04T15:50:28-07:00
Authentication code: 13

Problem with convert -resize

Post by stin »

I am very new to IM and having a problem. I'm sure it's simple but I haven't figured it out. I'm trying to convert a whole folder of png files and resize them. This is what I typed in the command line:

convert C:\FullFilePath\imgs\ -resize 50% *.png

I keep getting can't find directry and can't open *.png. The file path is correct.

I tried reading up on it, but with no success.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problem with convert -resize

Post by fmw42 »

Use mogrify instead of convert. It can handle a whole folder of images, resize them and then write then to the same folder overwriting your original image (bad idea) or to a new folder

see
http://www.imagemagick.org/Usage/basics/#mogrify
stin
Posts: 4
Joined: 2012-05-04T15:50:28-07:00
Authentication code: 13

Re: Problem with convert -resize

Post by stin »

Can you give me the syntax? I'm still missing something. I get the following errors:
1) unable to open image ... permission denied @ error/blob.c/OpenBlob/2619
2) no decode delegate for this image format ... @ error/constitute.c/ReadImage/544
(... is just to exclude the file path)

Thanks for the reply.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problem with convert -resize

Post by fmw42 »

suppose your images are in folder1. create a new directory called folder2

cd to folder 1
mogrify -path /path2/folder2 -format png -resize 50% *

or if you only want to limit it to certain format (so you don't try to convert some odd text file) in your folder1, then

mogrify -path /path2/folder2 -format png -resize 50% *.png *.gif *.jpg

I don't know if your filesystem will be case sensitive, but if it does just add the same in caps


mogrify -path /path2/folder2 -format png -resize 50% *.png *.gif *.jpg *.PNG *.GIF *.JPG


If you are on Windows, the some syntax will be different (apart from \ in place of / for paths). For example % needs to be escaped as %%.

See http://www.imagemagick.org/Usage/windows/
stin
Posts: 4
Joined: 2012-05-04T15:50:28-07:00
Authentication code: 13

Re: Problem with convert -resize

Post by stin »

Got it! Two things I was doing wrong -- I didn't escape the 50%% and I didn't have "format png" -- I don't remember seeing that before...

Thanks very much!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problem with convert -resize

Post by fmw42 »

the -format png says you want png to be the output format
stin
Posts: 4
Joined: 2012-05-04T15:50:28-07:00
Authentication code: 13

Re: Problem with convert -resize

Post by stin »

What does the *png do?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problem with convert -resize

Post by fmw42 »

it should be *.png

any way, it says look for and process all files that end in .png, but leave any files with other suffixes unprocessed.
Post Reply