Problems with resizing a previously rendered label

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?".
GarbageSauce
Posts: 23
Joined: 2016-12-08T19:43:17-07:00
Authentication code: 1151

Problems with resizing a previously rendered label

Post by GarbageSauce »

Okay so I have the newest version of ImageMagick installed on Windows 10 Pro 64-bit. I run this command

magick -background none -fill #ff0000 -font Arial -size x90 -gravity center label:"ALBUQUERQUE" png32:C:\Users\Nope\Desktop\asdf.png

And then I resize it (note that this command is applied to a crapton of labels all at difference sizes)

magick C:\Users\Nope\Desktop\asdf.png -resize 240x90^>! C:\Users\Nope\Desktop\asdf.png

If you run this command, you will see that the resized image looks all aliased and gross. Is there a way to keep this from happening?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Problems with resizing a previously rendered label

Post by snibgo »

The result I get isn't aliased.
Image
The image has been halved in width, so the letters are narrowed and pushed together. It may look better if you choose a font that already has narrow letters.
snibgo's IM pages: im.snibgo.com
GarbageSauce
Posts: 23
Joined: 2016-12-08T19:43:17-07:00
Authentication code: 1151

Re: Problems with resizing a previously rendered label

Post by GarbageSauce »

Wait. How are you getting a different result than me?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problems with resizing a previously rendered label

Post by fmw42 »

What is your exact IM version? What do you get from

Code: Select all

convert -version
Perhaps you have an older delegate for freetype or fontconfig?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problems with resizing a previously rendered label

Post by fmw42 »

I think your problem is with 240x90^>! I do not think you can use ! with ^>. They mean two different things.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problems with resizing a previously rendered label

Post by fmw42 »

On windows ^ is a special character an I think needs escaping as ^^

Or were you just escaping > as ^>?
GarbageSauce
Posts: 23
Joined: 2016-12-08T19:43:17-07:00
Authentication code: 1151

Re: Problems with resizing a previously rendered label

Post by GarbageSauce »

The -resize -240x90^>! argument is there simply to resize any images LARGER than 240x90 pixels down to 240x90 pixels without paying regard to the aspect ratio. If I remove the caret, it doesn't seem work properly.

And here is what magick -version returned
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problems with resizing a previously rendered label

Post by fmw42 »

The carat in IM means to display to conform to the smaller dimension. The > means only if the image is greater than that size. The ! means exactly to the dimensions you have. But in Windows, the ^ has a special meaning as an escape character. So your command as written is confusing to me and perhaps IM on Windows. In Windows syntax, you are escaping the >. Perhaps that is what you want. If you want it to check the smaller dimension, then it would need to be ^^>!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problems with resizing a previously rendered label

Post by fmw42 »

In unix (IM 7.0.4.7 Q16 Mac OSX), with the following, I get:

Code: Select all

magick -background none -fill "#ff0000" -font Arial -size x90 -gravity center label:"ALBUQUERQUE" png32:asdf.png

Code: Select all

magick asdf.png -resize 240x90>! tmp.png
This assumes you are not interested in conforming to the smaller dimension via ^ ( or in windows ^^)

Image

If you are, then I use:

Code: Select all

magick asdf.png -resize 240x90^>! albuqueque2.png
Image
GarbageSauce
Posts: 23
Joined: 2016-12-08T19:43:17-07:00
Authentication code: 1151

Re: Problems with resizing a previously rendered label

Post by GarbageSauce »

Okay let me re-explain. If the input image is larger than 240x90 pixels, resize to 240x90 pixels without respecting the aspect ratio. Here are all forms of arguments I tried.

240x90>!
Image
The dimensions are 240x37 so nope. Bad combo.

240x90^>!
Image
Dimensions are 240x90 so yes. This is what we want.... except that the output is downright ugly.

240x90^^>!
Image
Dimensions are 590x90. Identical to the original. Nope.

240x90>^!
Image
Dimensions are 240x37. Same as the first resize.

240x90\>!
Image
Dimensions are 240x37. Same as above.

240x90>\!
Returns Access is Denied. I'm guessing this isn't the way to go.

I'm not entirely sure what is going on.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problems with resizing a previously rendered label

Post by fmw42 »

You appear to be on Windows from your C:\. So you need to use Windows syntax. In Windows ^ is escape and so your original command was escaping the >. If you really want the IM ^, then you must escape it to ^^. See http://www.imagemagick.org/script/comma ... p#geometry for the meaning of ^, >, ! in IM.
GarbageSauce
Posts: 23
Joined: 2016-12-08T19:43:17-07:00
Authentication code: 1151

Re: Problems with resizing a previously rendered label

Post by GarbageSauce »

Okay let's start from scratch. If I want to resize the image to 240x90 without respecting the aspect ratio and while retaining image quality, how do I make it so. I only stuck with the caret because it got my image down to the desired dimensions but I just couldn't figure out why it looked hideous.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Problems with resizing a previously rendered label

Post by snibgo »

What happens when you use just a "!" ? What does your original look like, before resizing?
snibgo's IM pages: im.snibgo.com
GarbageSauce
Posts: 23
Joined: 2016-12-08T19:43:17-07:00
Authentication code: 1151

Re: Problems with resizing a previously rendered label

Post by GarbageSauce »

Here is the original
Image

Just doing -resize 240x90! gets me this
Image
The dimensions are 240x90 which is exactly what I want. I just can't have it looking like garbage.

This image was done on a different computer running a different version of IM with a different and less stable font although the process was identical.
Image
I did try using this font on my computer with the newest release of IM and it looks like garbage.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problems with resizing a previously rendered label

Post by fmw42 »

Check your version of freetype? Also perhaps you got a bad set of glyphs in the Arial font you downloaded or are using. I do not see aliasing except in your middle imager above. Perhaps your arial font is set to Arial narrow?. Check your fonts by

Code: Select all

convert -list font
You can find your version of freetype by

Code: Select all

convert -list format

TTC* TTF r-- TrueType font collection (Freetype 2.6.5)
TTF* TTF r-- TrueType font (Freetype 2.6.5)
Post Reply