Recreate a driver's license/passes with image and text
Re: Recreate a driver's license/passes with image and text
Getting close with this code:
$cmd = "/usr/bin/convert fitness.jpg \
\( ". $profile_pic ." -resize 300 -rotate -5 \) -geometry +20+20 -composite \
\( paperclip.png -rotate -5 \) -geometry +40+10 -composite \
final_image.jpg
";
I might need a bit of help
https://wmforum.nl/sample3.jpg
When i remove the rotation and move the clip up by -5 pixels it looks perfect, just not rotated
$cmd = "/usr/bin/convert fitness.jpg \
\( ". $profile_pic ." -resize 300 -rotate -5 \) -geometry +20+20 -composite \
\( paperclip.png -rotate -5 \) -geometry +40+10 -composite \
final_image.jpg
";
I might need a bit of help
https://wmforum.nl/sample3.jpg
When i remove the rotation and move the clip up by -5 pixels it looks perfect, just not rotated
Re: Recreate a driver's license/passes with image and text
Got it:
$cmd = "/usr/bin/convert fitness.jpg \
\( ". $profile_pic ." -resize 300 -alpha set -background none -rotate -5 \) -geometry +20+20 -composite \
\( paperclip.png \) -geometry +40+29 -composite \
final_image.jpg
Almost perfect
https://wmforum.nl/sample4.jpg
$cmd = "/usr/bin/convert fitness.jpg \
\( ". $profile_pic ." -resize 300 -alpha set -background none -rotate -5 \) -geometry +20+20 -composite \
\( paperclip.png \) -geometry +40+29 -composite \
final_image.jpg
Almost perfect
https://wmforum.nl/sample4.jpg
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Recreate a driver's license/passes with image and text
Since you are on IM 7, the syntax is slightly different. Replace "convert" with "magick".
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Recreate a driver's license/passes with image and text
Using convert with IM 7, depending upon your set-up, may be actually using IM 6 code. In this example, there is likely no difference. But best to switch to using "magick" when using IM 7 to get all the newer features of IM 7.
For other tools, you will need to preface them with magick. So in IM 7, it would be magick compare, magick mogrify, magick montage, magick identify, etc. But not magick convert. Here it is only magick.
For other tools, you will need to preface them with magick. So in IM 7, it would be magick compare, magick mogrify, magick montage, magick identify, etc. But not magick convert. Here it is only magick.
Re: Recreate a driver's license/passes with image and text
Thanks Fred. My script is now done and I'll implement it for whatever feature soon.
This is the final code (for now)
$cmd = "/usr/bin/magick happy-bd.jpg \
\( ". $profile_pic ." -resize 200 -alpha set -background none -rotate -5 \) -geometry +20+10 -composite \
\( paperclip.png \) -geometry +30+15 -composite \
\( -background none -fill white -font \"./lib/impact.ttf\" -size 500x100 -gravity Center caption:'Kim, we hope to see you soon!\nCODE: FDGHF4G65' \) -gravity South -geometry +0+150 -composite \
-quality 40 final_image.jpg
";
Although it does look exactly how I wanted it to look, I think the thumb/profile image could be better. It's kinda dull/boring as is. I've seen many more fun projects using this stuff. Like the (note, not my taste) "IM Legend" - bookcovers you saw for a while on FB walls. It was done pretty well, getting those images ligned up almost perfect.
I got some cool ideas when i saw that half transparent glassy 3d buttons in the IM help sections.
This is the final code (for now)
$cmd = "/usr/bin/magick happy-bd.jpg \
\( ". $profile_pic ." -resize 200 -alpha set -background none -rotate -5 \) -geometry +20+10 -composite \
\( paperclip.png \) -geometry +30+15 -composite \
\( -background none -fill white -font \"./lib/impact.ttf\" -size 500x100 -gravity Center caption:'Kim, we hope to see you soon!\nCODE: FDGHF4G65' \) -gravity South -geometry +0+150 -composite \
-quality 40 final_image.jpg
";
Although it does look exactly how I wanted it to look, I think the thumb/profile image could be better. It's kinda dull/boring as is. I've seen many more fun projects using this stuff. Like the (note, not my taste) "IM Legend" - bookcovers you saw for a while on FB walls. It was done pretty well, getting those images ligned up almost perfect.
I got some cool ideas when i saw that half transparent glassy 3d buttons in the IM help sections.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Recreate a driver's license/passes with image and text
In the future, when you need some help, it would be good idea to post the input images independently and not in one composite. That way, we can try to reproduce your result from your actual input.
Re: Recreate a driver's license/passes with image and text
Hi Fred, I do actually have a question about an option that bugs me
This is my final code now (urls removed):
/usr/bin/magick /happy-bd.jpg \
\( https://91e8b811d51b1474a21fbe.jpg -resize 200 -bordercolor white -border 6 -bordercolor grey60 -border 1 -alpha set -background none -rotate -5 \) -geometry +20+10 -composite \
\( /paperclip.png \) -geometry +30+17 -composite \
\( -background none -fill white -font ./lib/felt.ttf -size 480x100 -gravity Center caption:'Hi {{NAME}}, we hope to see you soon!
CODE: FREEDESSERT' -trim -bordercolor rgba\(0,0,0,0.5\) -border 10 \) -gravity South -geometry +0+120 -composite \
-quality 65 /1541329006.jpg
The last section which adds the text has a 50% transparent black background, but I'm not able to succesfully add a border around that rectangle. When i add/use things like the following the best I got was it placed an entire rectangle of the border/stroke color under the text again instead of just the outline around my 50% black background:
-fill none -stroke white
or
-stroke white -strokewidth 1
or (a variation of)
-shave
I did have a working version of this with the PHP version where i used draw based on XY co-ordinated, but now i am using this cmd version (which is much better).
Am I missing some basic fundamental and correct way of writing this code?
Last but not least, if you don't mind i have two other questions. Don't want to start a new thread just for those:
1. For a digital loyalty card, we now use 5 JPGs each corresponds to a stamp (1-5), but I think this would work great with unlimited stamps (max. is set in script settings). If I were to use a stamp.png file (much like the paperclip in the above sample) and want to put those in a random (natural stamped) XY(+slightly rotated) position in a certain area (like lower third of image), what would you suggest is the best way for that? Clone, Tile, Copy? I would basicly check with my script how many stamps a person already has and then add one to it until the end is reached in which case they have 0 again. I can use a while loop to print the X stamps.
2 (solved, sort of). Can you point me to a manual where i can find what these syntaxes preceeded by : mean, like rose: in this sample "convert rose: -crop". I think i read it means it is stored in cache and that name (rose) can be anything, but when do you use that? And then there were all those other "name:" variations I saw, but not where i could find the explanantions.
Edit: found another sample just now "xd:" in
convert xc:red -bordercolor yellow -border 1 \
-filter Gaussian +distort SRT 33,0 -normalize dot_distort.jpg
Edit2: I now know canvas: is the newer xd:, but still not sure what to do with it:) I assume rose: is the name of the canvas(?)
Edit3 (just in case others read this who are not sure what it means:
An image name ending with a colon ":" is a built-in facility of ImageMagick, rather than a file that contains an image.
"rose:" is an image that is built-in to ImageMagick. Instead of using a filename, "rose:" simply provides a standard test image. Other built-in images include "wizard:" and "logo:".
https://www.imagemagick.org/discourse-s ... hp?t=30201
I appreciate your awesome willingness to keep sharing all these years, almost all threads I read have your name in it:)
This is my final code now (urls removed):
/usr/bin/magick /happy-bd.jpg \
\( https://91e8b811d51b1474a21fbe.jpg -resize 200 -bordercolor white -border 6 -bordercolor grey60 -border 1 -alpha set -background none -rotate -5 \) -geometry +20+10 -composite \
\( /paperclip.png \) -geometry +30+17 -composite \
\( -background none -fill white -font ./lib/felt.ttf -size 480x100 -gravity Center caption:'Hi {{NAME}}, we hope to see you soon!
CODE: FREEDESSERT' -trim -bordercolor rgba\(0,0,0,0.5\) -border 10 \) -gravity South -geometry +0+120 -composite \
-quality 65 /1541329006.jpg
The last section which adds the text has a 50% transparent black background, but I'm not able to succesfully add a border around that rectangle. When i add/use things like the following the best I got was it placed an entire rectangle of the border/stroke color under the text again instead of just the outline around my 50% black background:
-fill none -stroke white
or
-stroke white -strokewidth 1
or (a variation of)
-shave
I did have a working version of this with the PHP version where i used draw based on XY co-ordinated, but now i am using this cmd version (which is much better).
Am I missing some basic fundamental and correct way of writing this code?
Last but not least, if you don't mind i have two other questions. Don't want to start a new thread just for those:
1. For a digital loyalty card, we now use 5 JPGs each corresponds to a stamp (1-5), but I think this would work great with unlimited stamps (max. is set in script settings). If I were to use a stamp.png file (much like the paperclip in the above sample) and want to put those in a random (natural stamped) XY(+slightly rotated) position in a certain area (like lower third of image), what would you suggest is the best way for that? Clone, Tile, Copy? I would basicly check with my script how many stamps a person already has and then add one to it until the end is reached in which case they have 0 again. I can use a while loop to print the X stamps.
2 (solved, sort of). Can you point me to a manual where i can find what these syntaxes preceeded by : mean, like rose: in this sample "convert rose: -crop". I think i read it means it is stored in cache and that name (rose) can be anything, but when do you use that? And then there were all those other "name:" variations I saw, but not where i could find the explanantions.
Edit: found another sample just now "xd:" in
convert xc:red -bordercolor yellow -border 1 \
-filter Gaussian +distort SRT 33,0 -normalize dot_distort.jpg
Edit2: I now know canvas: is the newer xd:, but still not sure what to do with it:) I assume rose: is the name of the canvas(?)
Edit3 (just in case others read this who are not sure what it means:
An image name ending with a colon ":" is a built-in facility of ImageMagick, rather than a file that contains an image.
"rose:" is an image that is built-in to ImageMagick. Instead of using a filename, "rose:" simply provides a standard test image. Other built-in images include "wizard:" and "logo:".
https://www.imagemagick.org/discourse-s ... hp?t=30201
I appreciate your awesome willingness to keep sharing all these years, almost all threads I read have your name in it:)
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Recreate a driver's license/passes with image and text
To add a border around a transparent image without the border color filling the background, make sure you set the compose method to "copy" before applying the border. The first command here will fill the background with the border color. The second will just add the border around the image.kimmyk wrote: ↑2018-11-04T04:20:36-07:00The last section which adds the text has a 50% transparent black background, but I'm not able to succesfully add a border around that rectangle. When i add/use things like the following the best I got was it placed an entire rectangle of the border/stroke color under the text again instead of just the outline around my 50% black background:
Code: Select all
magick -background none -pointsize 100 label:"ABC 123" -border 10 doesntwork.png
magick -background none -pointsize 100 label:"ABC 123" -compose copy -border 10 works.png
Re: Recreate a driver's license/passes with image and text
As a part of my "larger scheme" this still creates a solid black rectangle:
...
\( -background none -fill white -font ./lib/felt.ttf -size 480x100 -gravity Center caption:'Hi {{NAME}}, we hope to see you soon!' -trim -bordercolor rgba\(0,0,0,0.5\) -border 10 -compose copy -border 10 \) -gravity South -geometry +0+120 -composite \
...
When pushed outside of the () it will create a border around the entire image as well as making the text rectangle black instead of 50% opaque
...
\( -background none -fill white -font ./lib/felt.ttf -size 480x100 -gravity Center caption:'Hi {{NAME}}, we hope to see you soon!' -trim -bordercolor rgba\(0,0,0,0.5\) -border 10 -compose copy -border 10 \) -gravity South -geometry +0+120 -composite \
...
When pushed outside of the () it will create a border around the entire image as well as making the text rectangle black instead of 50% opaque
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Recreate a driver's license/passes with image and text
As GeeMack says, but note that kimmyk's command uses a composite after that border operation, so that should include "-compose Over" because the default won't be used.
For builtin images like "rose:", see http://www.imagemagick.org/script/forma ... tin-images .
The same page describes pseudo-image formats such as "xc:".
For builtin images like "rose:", see http://www.imagemagick.org/script/forma ... tin-images .
The same page describes pseudo-image formats such as "xc:".
snibgo's IM pages: im.snibgo.com
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Recreate a driver's license/passes with image and text
(Writing while snibgo was replying...) After adding the border you'll have to change the compose method back to "over", or whatever compose method is required before doing another composite...kimmyk wrote: ↑2018-11-04T06:19:14-07:00As a part of my "larger scheme" this still creates a solid black rectangle:
...
\( -background none -fill white -font ./lib/felt.ttf -size 480x100 -gravity Center caption:'Hi {{NAME}}, we hope to see you soon!' -trim -bordercolor rgba\(0,0,0,0.5\) -border 10 -compose copy -border 10 \) -gravity South -geometry +0+120 -composite \
...
Code: Select all
... -compose copy -border 10 -compose over ...
Re: Recreate a driver's license/passes with image and text
That works
...
\( -background none -fill white -font ./lib/felt.ttf -size 480x100 -gravity Center caption:'Hi {{NAME}}, we hope to see you soon!' -trim -bordercolor rgba\(0,0,0,0.5\) -border 10 -compose copy -bordercolor black -border 1 -compose over \) -gravity South -geometry +0+120 -composite \
...
Thanks.
...
\( -background none -fill white -font ./lib/felt.ttf -size 480x100 -gravity Center caption:'Hi {{NAME}}, we hope to see you soon!' -trim -bordercolor rgba\(0,0,0,0.5\) -border 10 -compose copy -bordercolor black -border 1 -compose over \) -gravity South -geometry +0+120 -composite \
...
Thanks.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Recreate a driver's license/passes with image and text
Draw the text inside your parenthes for for my image.jpg using -annotate or create a new transparent image with your text using label:
See https://imagemagick.org/Usage/text/
See https://imagemagick.org/Usage/text/