Page 1 of 1

Inconsistent Auto Sizing with Caption

Posted: 2015-10-23T07:43:01-07:00
by dlombardi
I'm having some trouble getting consistent results using the caption function. I'm attempting to create a simple image with a quote and have it auto wrap and auto size to fill the size of the image. It appears that when one of the lines of the caption are a certain length, the auto sizing of the text does not compute properly.

In the test python script below, I have it creating an image of the original version of a quote that's having the problem (I have several other examples also). It then creates an image of the original quote, but with a word removed to show that the problem goes away. It then creates an image of the original quote, but with an extra word added to show that the problem goes away then also. Below the script, you can see the resulting images that get created by that script.

If you'd like to reproduce, the font I'm using is called "Mom's Typewriter". You can install it by searching for Mom«t__.ttf or grab it from here: http://www.dafont.com/moms-typewriter.font

Thanks kindly!
Dave


Windows 7
ImageMagick 6.9.2-0 Q16 (32bit)
Python 2.7
Wand-0.4.1


Code: Select all

# ================== Start of Python Test Script ================== 

def makeImage(quote,filename):
	from wand.image import Image
	from wand.color import Color
	from wand.font import Font
	
	rootPath = "C:\\Users\\Dave\\Desktop\\ImageTesting\\"
	
	print("\nProcessing " + filename)	
	with Image(width=853, height=480, background=Color('black')) as image:
		image.caption(quote, font=Font(path=rootPath+'MomType.ttf', color=Color('gray20')), gravity='north')
		image.save(filename=rootPath+filename)
	print('Processing complete.')
	
#===============================================================================================================================
# This is the original quote that does not fill the image.
#===============================================================================================================================
quoteToAdd = "How can you squander even one more day not taking advantage of the greatest shifts of our generation? How dare you settle for less when the world has made it so easy for you to be remarkable?\n\n- Seth Godin" + "\n"
filenameToUse = "OriginalQuote.jpg"
makeImage(quoteToAdd,filenameToUse);

#===============================================================================================================================
# This is the original quote, but with the word "our" removed before "generation".  This will mostly fill the image properly.
#===============================================================================================================================
quoteToAdd = "How can you squander even one more day not taking advantage of the greatest shifts of generation? How dare you settle for less when the world has made it so easy for you to be remarkable?\n\n- Seth Godin" + "\n"
filenameToUse = "OriginalMinusWord.jpg"
makeImage(quoteToAdd,filenameToUse);

#===============================================================================================================================
# This is the original quote, but with the word "this" added before "our generation".  This will mostly fill the image properly.
#===============================================================================================================================
quoteToAdd = "How can you squander even one more day not taking advantage of the greatest shifts of this our generation? How dare you settle for less when the world has made it so easy for you to be remarkable?\n\n- Seth Godin" + "\n"
filenameToUse = "OriginalPlusWord.jpg"
makeImage(quoteToAdd,filenameToUse);

# ================== End of Python Test Script ================== 

Resulting images:

This is the original quote that does not fill the image.
https://drive.google.com/open?id=0B0wlA ... 3ctOENGWEE
Image

This is the original quote, but with the word "our" removed before "generation". This will mostly fill the image properly.
https://drive.google.com/open?id=0B0wlA ... UN2VzJRYUk
Image

This is the original quote, but with the word "this" added before "our generation". This will mostly fill the image properly.
https://drive.google.com/open?id=0B0wlA ... XFodUdQY3M
Image

Re: Inconsistent Auto Sizing with Caption

Posted: 2015-10-29T17:15:56-07:00
by magick
Does your Python script translate to this command-line?
  • convert -size 853x480 -background black -fill gray20 -gravity north -font MomType.ttf caption:"How can you squander even one more day not taking advantage of the greatest shifts of our generation? How dare you settle for less when the world has made it so easy for you to be remarkable?\n\n- Seth Godin\n" OriginalQuote.jpg
If so, it renders properly for us with the latest ImageMagick release, 6.9.2-4.