LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-02-2020, 12:50 PM   #1
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
Imagemagick - Convert: Positioning text


I'm using convert tp put some text on an image and I have one little niggling problem - I cannot see how to move the text to the center of the label:

Code:
charlie@charlie-machine:~/COOKING$ echo $T
--- Omelette ---
charlie@charlie-machine:~/COOKING$ convert IMG_3680.JPG -background Khaki -pointsize 80 -fill red -weight 700  label:"$T" +swap -gravity North -append IMG_3680-out.JPG
charlie@charlie-machine:~/COOKING$
And attached are the images before and after adding the text.

I want to move the red text to the centre of the khaki banner
Attached Thumbnails
Click image for larger version

Name:	IMG_3680.JPG
Views:	11
Size:	144.8 KB
ID:	33152   Click image for larger version

Name:	IMG_3680-out.JPG
Views:	11
Size:	146.9 KB
ID:	33153  
 
Old 05-02-2020, 02:08 PM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
I'd say it is centered horizontally - so you mean vertically? It's a font thing. Imagine you had a g, y or p letter there.
Add some padding, if possible more to the top than the bottom.
 
1 members found this post helpful.
Old 05-02-2020, 02:23 PM   #3
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Use -gravity. See here for example usage with labels.

Last edited by shruggy; 05-02-2020 at 02:28 PM.
 
1 members found this post helpful.
Old 05-02-2020, 05:12 PM   #4
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026

Original Poster
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
Quote:
Originally Posted by ondoho View Post
I'd say it is centered horizontally - so you mean vertically? It's a font thing. Imagine you had a g, y or p letter there.
Add some padding, if possible more to the top than the bottom.
Correct, I checked the font explanation and did a test which shows it is centred vertically, just looks odd so I would like to add padding to just shift the text down a bit in the banner.
Attached Thumbnails
Click image for larger version

Name:	IMG_3680-out.JPG
Views:	5
Size:	143.8 KB
ID:	33155  

Last edited by GPGAgent; 05-02-2020 at 05:24 PM.
 
Old 05-03-2020, 06:35 AM   #5
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026

Original Poster
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
This is the script as it stands, I need to pad the red text down a few point, bit I cannot figure out how to do it despite much DuckDucking
Code:
convert -fill red -weight 700 -pointsize 20 -gravity north -undercolor khaki -draw "text 0,0 '  Chicken with Sweet Chilli and Garlic'" IN.JPG OUT.JPG
Cheers
Attached Thumbnails
Click image for larger version

Name:	0999-new.jpg
Views:	12
Size:	127.4 KB
ID:	33158  
 
Old 05-03-2020, 07:17 AM   #6
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
How about
Code:
convert -background khaki -fill red -weight 700 -pointsize 20 -gravity north -splice 0x25 -annotate +0+20 '--- Omelette ---' IN.JPG OUT.JPG
 
1 members found this post helpful.
Old 05-04-2020, 06:09 AM   #7
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026

Original Poster
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
Thumbs up

Quote:
Originally Posted by shruggy View Post
How about
Code:
convert -background khaki -fill red -weight 700 -pointsize 20 -gravity north -splice 0x25 -annotate +0+20 '--- Omelette ---' IN.JPG OUT.JPG
Perfect, vary many thanks, bit of tweaking and this is exactly what I wanted to learn, I can apply this to other scripts. I tweaked the -annotate values.

Code:
convert -background khaki -fill red -weight 700 -pointsize 20 -gravity north -splice 0x25 -annotate +0+3 '---ABC  abcdefghijklmnopq XYZ ---' IMG_3680.JPG OUT.JPG
Attached Thumbnails
Click image for larger version

Name:	OUT.JPG
Views:	13
Size:	131.7 KB
ID:	33164   Click image for larger version

Name:	OUT-CLOSE.png
Views:	9
Size:	110.7 KB
ID:	33165  
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Pdf to text : Poppler-utils versus Convert/imagemagick? Xeratul Linux - Software 1 02-23-2013 12:44 PM
[SOLVED] Using convert from imagemagick package to convert multiple jpg files janis_169 Linux - Newbie 5 07-18-2010 04:22 PM
ImageMagick-Convert, resize width, keep aspect cadj Linux - Software 2 06-18-2010 05:10 PM
install ImageMagick-6.5.1-2 & ImageMagick-devel-6.5.1.2 in red hat mokkai Linux - Enterprise 4 04-16-2009 12:04 PM
where would I find ImageMagick's convert program? kuplo Linux - Software 1 01-12-2006 12:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration