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?".
Before I resize an image, I'd like to get the new dimensions. Rather than write code to calculate the new dimensions, can I just get Imagemagick to do it? Something like
What information specifically are you looking for? Depending upon what you want there may be other ways. If you just want new size information, that can can be computed with some fx: computations without actually resizing.
Yeah, that's what I'm thinking. I'd like to avoid reproducing the logic that does "-resize 100x100>", though I guess it's a standard enough algorithm. (Though not standard enough that Wordpress does it right! Until recently WP was often off-by-one on the rounding.)
This is Unix syntax. This will do it if you are using Linux, Mac OSX or Windows with Cygwin. If on plain Windows, another user will need to help as I do not have a PC or use Windows and the syntax for scripting is quite different.
Change the infile to whatever image you want rather than the IM internal logo: image and set tw and th to whatever resize values you want. The following script takes into account the equivalent of the > in the resize.
Thanks, that looks great and must match what IM does internally. If it misses on a corner case, no big deal, I've still saved processing time in the other 99% of cases.