Page 1 of 1

Add text on canvas of certain size

Posted: 2013-06-21T08:44:38-07:00
by Marcel71
Hi,

What i am trying to do:

1) I have a text with pointsize 30 and then i resize it. For example:

Code: Select all

convert -font Arial -pointsize 30 label:"Imagemagick" -resize 140% out.png
The resulting image is 280x50. And of-course, the text is a bit blurry.

Now i would like to have the same text with that size, but then sharp.

Code: Select all

convert -font Arial -gravity center -size 280x label:"Imagemagick" out2.png
There is a slight difference in font size, however that is not my main concern.
How do i merge above two commands in 1 convert?

I hoped something like:

Code: Select all

convert -respect-parentheses ( -font arial -pointsize 30 label:"Imagemagick" -resize 140% ) ( -size %wx -font arial -gravity center label:"Imagemagick" ) -delete 0 out.png
But it does not give me the same canvas size...

Any suggestions?

Re: Add text on canvas of certain size

Posted: 2013-06-21T09:23:36-07:00
by snibgo
What are you trying to do?

If you want a label that has pointsize 30 * 140% = 42, the obvious way is ...

Code: Select all

convert -font Arial -pointsize 42 label:"Imagemagick" out.png
... but I don't suppose this is what you want.

(Incidentally, I don't think you can use %w in "-size".)

Re: Add text on canvas of certain size

Posted: 2013-06-21T10:25:28-07:00
by Marcel71
Well, i would like for users to dynamically resize the text within my website.

So the "original" text is -pointsize 30.

Then with a 'slider' and jQuery i would like that users can resize the text bigger or smaller.
When moving the slider, the text (image) will get bigger or smaller immediatly in the preview.

However, after the text is resized with the slider, the text looks blurry in the browser. (logical, as the image has dynamically resized inside the browser)
So i want to fetch a new text after the user resized the text (image) on the website. So it looks sharp again.

You theory does not work.
As -pointsize 60 will not have doubled in size in comparison with -pointsize 30.

Thanks for the answer anyway.

Re: Add text on canvas of certain size

Posted: 2013-06-21T10:36:53-07:00
by fmw42
Withdrawn. GreenKoopa's code below explains it better.

Re: Add text on canvas of certain size

Posted: 2013-06-21T10:38:19-07:00
by GreenKoopa

Code: Select all

convert -respect-parentheses ^
( -font arial -pointsize 30 label:Imagemagick -resize 140%% ) ^
-set option:size "%%wx" +delete ^
( -font arial -gravity center label:Imagemagick ) ^
out.png
Windows script.

Re: Add text on canvas of certain size

Posted: 2013-06-21T10:57:39-07:00
by Marcel71
Thanks, i think indeed that GreenKoppa's code is the closest i can get with this issue :)
The out.png text is a bit smaller than the resized text. But i can live with that.

Thanks all...