Mogrify - resize to 72px w images that are wider than 72px

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
RKwasi
Posts: 11
Joined: 2016-03-26T17:07:28-07:00
Authentication code: 1151

Mogrify - resize to 72px w images that are wider than 72px

Post by RKwasi »

I'm trying to resize a few thousand images to be 72px wide to be used as thumbnails in slider galleries. These images are kept in a folder that also has thousands of images that are smaller than 72x wide that need to be kept their original size.....

The large images are a folder "test_photos" and I want place the resized thumbs into a folder I created called "test_photos_thumbnails"

Here's the command line code I'm using...
(got most of it from another mogrify thread about resizing)

mogrify -path c:\inetpub\wwwroot\rs-avs\test_photos_thumbnails -format jpg +distort srt "%[fx:(w>65 || h>65)x72]" *.jpg

gives me this error mesage:
mogrify.exe: unable to open image `c:\inetpub\wwwroot\avs\test_photos_thumbnails\durant-3-12-15-1.jpg': No such file or directory @ error/blob.c/OpenBlob/2702.



This "sorta" works
mogrify -path c:\inetpub\wwwroot\avs\test_photos -format jpg +distort srt "%[fx:(w>65 || h>65)x72]" *.jpg

Except it resizes some images in the original folder by a few pixels here and there, so that line of code is no good to use either. As an example it makes an existing image that was 60x60 become 62x62


What am I doing wrong??
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Mogrify - resize to 72px w images that are wider than 72px

Post by GeeMack »

RKwasi wrote:I'm trying to resize a few thousand images to be 72px wide to be used as thumbnails in slider galleries. These images are kept in a folder that also has thousands of images that are smaller than 72x wide that need to be kept their original size.....
Unless I've misunderstood what you're trying to do, it seems like this would get it done...

Code: Select all

mogrify -path "c:\path-to\output-directory" -format jpg -resize ^>72x *.jpg
That would resize everything that is wider than 72 pixels down to 72, while not resizing anything 72 pixels wide or less. It would put all the output files in "c:\path-to\output-directory" as JPGs by their original names. Note that running the command on a Windows OS probably requires escaping the greater-than ">" with a caret like in my example.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Mogrify - resize to 72px w images that are wider than 72px

Post by snibgo »

RKwasi wrote:+distort srt "%[fx:(w>65 || h>65)x72]"
This is bad syntax. Text between "%[fx:" and "]" should be an arithmetic expression, but yours isn't because "x" isn't an arithmetical operator.

"+distort srt" needs two or more numbers. Each number can be an "fx" expression.

ImageMagick doesn't always report bad syntax, and may do something unexpected. What it does will vary between IM versions, or some random factor.
snibgo's IM pages: im.snibgo.com
RKwasi
Posts: 11
Joined: 2016-03-26T17:07:28-07:00
Authentication code: 1151

Re: Mogrify - resize to 72px w images that are wider than 72px

Post by RKwasi »

I'm a newbie at something this intricate.

Thanks for the tips.
I'll give them a try when I'm back at my office......
RKwasi
Posts: 11
Joined: 2016-03-26T17:07:28-07:00
Authentication code: 1151

Re: Mogrify - resize to 72px w images that are wider than 72px

Post by RKwasi »

OK
It sorta works

The original photos are in test_photos
I am in the test_photos directory as I run the command from the command line......
I want to place the reduced images into test_photos_thumbnails

mogrify -path c:\inetpub\wwwroot\avs\test_photos_thumbnails -format jpg -resize ^>72x *.jpg

I get this error:
mogrify.exe: unable to open image `c:\inetpub\wwwroot\avs\test_photos_thumbnails\durant-3-12-15-1.jpg': No such file or directory @ error/blob.c/OpenBlob/2702.

doesn't work, because the original photo "durant-3-12-15-1.jpg" is located in the directory "test_photos"


If I use:
mogrify -path c:\inetpub\wwwroot\avs\test_photos -format jpg -resize ^>72x *.jpg
it works, skipping the images that are 60x60, but it overwrites all the original photos in "test_photos" and places nothing into "test_photos_thumbnails"


Am I not able to place the new images into a new directory?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mogrify - resize to 72px w images that are wider than 72px

Post by fmw42 »

-path is the directory where you want to place the output images and must exist. IM does not create a new directory.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Mogrify - resize to 72px w images that are wider than 72px

Post by GeeMack »

RKwasi wrote:... it works, skipping the images that are 60x60, but it overwrites all the original photos in "test_photos" and places nothing into "test_photos_thumbnails" [...] Am I not able to place the new images into a new directory?
It looks like the kind of problem you might have if there was a typo in the name of your destination directory, maybe a hyphen instead of an underscore, a space at the beginning or end that you've overlooked, something like that. Or it may even be a destination directory that you don't have permission to write to. Your IM command seems to be working, especially if it works in your current directory.
RKwasi
Posts: 11
Joined: 2016-03-26T17:07:28-07:00
Authentication code: 1151

Re: Mogrify - resize to 72px w images that are wider than 72px

Post by RKwasi »

Still not going well

I'm able to copy a file via dos from "test_photos" into the directory "test_photos_thumbnails" so permissions can't be a problem.
copy durant-3-12-15-1.jpg c:\inetpub\wwwroot\avs\test_photos\test_photos_thumbnails

Running this:
mogrify -path c:\inetpub\wwwroot\avs\test_photos_thumbnails -format jpg -resize ^>72x *.jpg
I get this error message again:
mogrify.exe: unable to open image `c:\inetpub\wwwroot\avs\test_photos_thumbnails\durant-3-12-15-1.jpg': No such file or directory @ error/blob.c/OpenBlob/2702.

Why am I being told mogrify can't open image "durant-3-12-15-1.jpg" in the directory \test_photos\thumbnails

if I'm resizing and just placing durant-3-12-15-1.jpg into that directory I shouldn't be getting an "unable to open image" error... Right?
No reason it should be looking in that 2nd directory for that file......

Darn puzzling
RKwasi
Posts: 11
Joined: 2016-03-26T17:07:28-07:00
Authentication code: 1151

Re: Mogrify - resize to 72px w images that are wider than 72px

Post by RKwasi »

OK, Well this is real weird but things are better

If I create a folder at the root of my drive
c:\test_photos
and place my test files in there, and then make the NEW folder within \test_photos\thumbnails
.... and then run
mogrify -path c:\test_photos\test_photos_thumbnails -quality 100 -format jpg -resize ^>72x *.jpg

All behaves EXACTLY as I want it to.... YEAH!

It seems that when I try to run this mogrify command within folders over at c:\inetpub\wwwroot ... etc. it all fails with the error messages I've been indicating here. I'm doing all this on my windows7 desktop where I have IIS installed and use it as my development server....

Any ideas why I would have these issues???

I can move forward with this but I'm just puzzled why I maight have been having all these issues within c:\inetpub........
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Mogrify - resize to 72px w images that are wider than 72px

Post by snibgo »

RKwasi wrote:mogrify.exe: unable to open image `c:\inetpub\wwwroot\avs\test_photos_thumbnails\durant-3-12-15-1.jpg': No such file or directory @ error/blob.c/OpenBlob/2702.
From the code, I think you'll get the same message if the file can't be opened for read, or opened for write.
snibgo's IM pages: im.snibgo.com
RKwasi
Posts: 11
Joined: 2016-03-26T17:07:28-07:00
Authentication code: 1151

Re: Mogrify - resize to 72px w images that are wider than 72px

Post by RKwasi »

Understood, but its still weird that all works as expected when I'm no longer within c:\inetpub and the actual directory for the site.
And yes, all folders within have correct read/write permissions etc
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Mogrify - resize to 72px w images that are wider than 72px

Post by GeeMack »

RKwasi wrote:Understood, but its still weird that all works as expected when I'm no longer within c:\inetpub and the actual directory for the site.
And yes, all folders within have correct read/write permissions etc
It looks like everything is good with the IM task you're trying to accomplish. There are some known idiosyncrasies with permissions for folders in the directory structure under "c:\inetpub" with IIS. I Googled "IIS inetpub permission" and found a lot of discussions on other forums about issues very similar to yours. That'd be your best place to find out how to resolve those parts of the problem.
Post Reply