Using pointsize for measures

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
emino
Posts: 8
Joined: 2014-01-07T19:41:32-07:00
Authentication code: 6789

Using pointsize for measures

Post by emino »

Firstly i'd like to say that i read / searched as much as i could, but didnt find anything about this.

Simply, can we use pointsize as a measurement - very much like "em"s in css - ? For example I want my caption to go 3 pointsize left from initial position; just like you would do in css left: 3em; can you do something similar in IM ?

-geometry +5%-3em ??

PS: Thank you for the great script & extensive documentation and examples. Pretty much everything is in there.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Using pointsize for measures

Post by fmw42 »

I believe that IM only supports pixels and percent at this time for positioning. I have no idea if "em's" will be supported at a later time or not.
emino
Posts: 8
Joined: 2014-01-07T19:41:32-07:00
Authentication code: 6789

Re: Using pointsize for measures

Post by emino »

I guess so. But i think it'd help a lot with captions if it could be implemented. Because if you have a variable pointsize, or multiple captions, it's almost impossible to define the right margins based on px / %.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Using pointsize for measures

Post by snibgo »

A useful trick is to put spaces at the start and end of captions eg

Code: Select all

convert -pointsize 30 caption:"   šŋĩβģő   " s.png
snibgo's IM pages: im.snibgo.com
emino
Posts: 8
Joined: 2014-01-07T19:41:32-07:00
Authentication code: 6789

Re: Using pointsize for measures

Post by emino »

snibgo wrote:A useful trick is to put spaces at the start and end of captions eg

Code: Select all

convert -pointsize 30 caption:"   šŋĩβģő   " s.png
Yes i've figured that for horizontal spacing, but my problem is with vertical spacing. i have to set an -extent for the caption, to go right below the one above it.

What i am trying to achieve is to auto-fit a quote in a 1280x520 area & place the author right below it, but with smaller pointsize ( With -pointsize 60% ). I can not know for sure how big 60% will be since the primary quote is auto-fit.
Here is a preview :
[img=http://s18.postimg.org/yukiqkpad/aqqqap ... tled_1.jpg]

So i currently assume a pointsize of 60 and thus 520 + 60 = 580. But ideally i would like to make it 520 + 1em, so it stays in the same place always. Current view:
[img=http://s27.postimg.org/6toxp1fan/spacci_Clipboard01.jpg]

Cant i grab the current font-size for that calculated -pointsize 60% somehow ?

PS: To clarify; i'd be perfectly fine adding \n's and spaces to the primary quote text. BUT problem is i want 60% size of the primary pointsize, which is automatically calculated.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Using pointsize for measures

Post by snibgo »

"-debug annotate" gives both the pointsize and pixels per em.

Code: Select all

convert -debug annotate -pointsize 30 caption:"šŋĩβģő" s.png
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Using pointsize for measures

Post by fmw42 »

I think you can adjust the line height by using http://www.imagemagick.org/script/comma ... ne-spacing interline-spacing.

Also what I usually do is apply -trim +repage after creating the text image and then apply -border to pad it out.
emino
Posts: 8
Joined: 2014-01-07T19:41:32-07:00
Authentication code: 6789

Re: Using pointsize for measures

Post by emino »

Thank you for the responses, +trim + repage allows you to start over, but i couldnt not find a way to make a -transparent, 520px- border top only to pad it from the top.
Also, as it turns out; i could not be more wrong about this. I.e; i thought i was inheriting the pointsize from the main text and getting 60% of it but it was actually getting 60% of the total size.
So, I give up; i'll just use fixed sizes i guess.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Using pointsize for measures

Post by fmw42 »

emino wrote:Thank you for the responses, +trim + repage allows you to start over, but i couldnt not find a way to make a -transparent, 520px- border top only to pad it from the top.
Also, as it turns out; i could not be more wrong about this. I.e; i thought i was inheriting the pointsize from the main text and getting 60% of it but it was actually getting 60% of the total size.
So, I give up; i'll just use fixed sizes i guess.

You can pad just the top with transparency using -background none -gravity north -splice ...

see
http://www.imagemagick.org/Usage/crop/#splice
emino
Posts: 8
Joined: 2014-01-07T19:41:32-07:00
Authentication code: 6789

Re: Using pointsize for measures

Post by emino »

Thank you, yes -splice did help me to apply a vertical padding (in the below image i'll just change the red to transparent in the production).

The only thing i cant do is to get the 60% of the quote text's size to apply to "albert einstein" text. But i think i'll just go with a fixed -48 something pointsize.

Image
Post Reply