I was trying to add a text on pdf page 2
by the command
convert -density 300 input.pdf -pointsize 80 -draw "text 400,550 'HeLLO'" out.pdf
I can add the text on page 1.
But
convert -density 300 input.pdf -pointsize 80 -draw "text 400,550 'HeLLO'" out.pdf
Wont work on page 2.
I tried to split it and add text one by one but that is too slow.
Is there a way I can draw a text on both page 1 and 2 directly in one command?
Thanks!
Try:
convert -density 300 input.pdf[1] -pointsize 80 -draw "text 400,550 'HeLLO'" out.pdf
Thinking about this it will only output page 2 and not the whole pdf?
Looking at this post https://stackoverflow.com/questions/10429311/creating-thumbnail-image-from-the-first-page-of-pdf you should be able to do:
convert -density 300 input.pdf[0-1] -pointsize 80 -draw "text 400,550 'HeLLO'" out.pdf
Related
I'd like to draw a text onto an image in a way like this:
convert -quality 100 -font Oswald-Regular -pointsize 515 -fill black -draw "text 1339.0,1099 'some text'" /tmp/ascript.png /tmp/ascript.png
and I need to know the dimensions of the text with the above parameters (size, font, text). How can I get that?
I tried something like this:
convert -size 5000x1500 xc:lightblue -font Oswald-Regular -pointsize 515 -fill none -undercolor white -annotate +20+100 'some text' -trim info:
but it's giving false result:
xc:lightblue XC 1834x250 5000x1500+19+0 16-bit sRGB 0.010u 0:00.000
.
What is the proper way (or a working way) to get the dimension of a drawn image based on this 3 parameters (font, size, text)?
I'm not strictly binded to ImageMagick, it can be any command line tool for the Linux shell, however, the text will be drawn by convert.
There are a couple simple ways to get the dimensions using ImageMagick with commands like this...
convert -size 5000x1500 xc:lightblue -font Oswald-Regular -pointsize 515 \
-fill none -undercolor white -annotate +20+100 'some text' \
-format "%[#]\n" info:
That uses the FX escape "%#" as the formatting string for the "info:" output. It will show IM's calculation of the after-trim width, height, horizontal offset, and vertical offset like "WxH+X+Y".
This similar command just gives the width and height of the trimmed text...
convert -size 5000x1500 xc:lightblue -font Oswald-Regular -pointsize 515 \
-fill none -undercolor white -annotate +20+100 'some text' \
-trim +repage -format "%[w]x%[h]\n" info:
That will trim the text, reset the paging geometry with "+repage", then output a string showing "WxH".
––– Edited to Add –––
I tried your image with_text.png with these commands. The output immediately follows each command...
convert with_text.png -format "%[#]\n" info:
1807x389+512+115
convert with_text.png -trim +repage -format "%[w]x%[h]\n" info:
1807x389
Those were tested with IMv6.8.9-9 on ubuntu bash on Windows 10. If you use that actual image and those commands, I'm not sure why you would get different results.
I use this code to auto generate slides from a .txt file where I wrote captions this way:
CAPTION 1
CAPTION 2
...
CAPTION N
This is the script I use
#!/bin/bash
i=0
# loop through files
while IFS= read -r p; do
# if it's not an empty line
if ! [ -z "$p"]; then
# echo line
echo "$p";
convert -background none -font Trebuchet-MS -fill white -pointsize 60 -gravity center -draw "text 0,300 'pango:$p'" slide_template.png slides/slide-$i.png
i=$((i+1))
fi;
# pass input
done <$#
slide_template.png is simply an empty (transparent) 1920x1080 png.
I pass my .txt file this way:
$ sh my_script.sh my_file.txt
And it generates my slides in /slides.
Now I'd like to use some format code into my slides, like
MY <b>CAPTION</b> 1
MY <i>CAPTION</i> 2
...
MY CAPTION N
But I can't understand how to use pango in my previous code. I need to reposition my caption line centered, 300 pixels from the bottom.
If I use:
convert -background none -font Trebuchet-MS -fill white -pointsize 60 -gravity center -draw "text 0,300 '$p'" slide_template.png slides/slide-$i.png
I get:
If I use this line:
convert -background none -font Trebuchet-MS -fill white -pointsize 60 -gravity center pango:"$p" slide_template.png slides/slide-$i.png
I get TWO files (why?), where the first one is correctly parsed but cropped to the text size:
And the second one is the background. Filenames this way are slide-0-0.png and slide-0-1.png
Solved: I need to pipe one image to another.
The first contains the formatted code, the second overlays the piped data onto the background.
#!/bin/bash
i=0
# loop through files
while IFS= read -r p; do
# if it's not an empty line
if ! [ -z "$p"]; then
convert -background none -font Trebuchet-MS -fill white -pointsize 60 -gravity center -size 1920x300 pango:"$p" png:- | convert slide_template.png png:- -geometry +0+800 -composite slides/slide-$i.png
i=$((i+1))
fi;
# pass input
done <$#
I am using imagemagick to create some simple graphics using the Dymo font. Here is an example:
convert -background White -fill DarkRed -font Dymo -pointsize 72 label:"DYMO FONT" -trim name.png
This command creates a file that looks like this:
I would like the red to fill all the way across, so that the image looks like a single label. I plan to use this on a page with a black background, which makes it look even worse.
I have played around with this for a while with no luck. Help would be appreciated.
Version: ImageMagick 6.9.2-7 Q16 x86_64 2015-12-06
O/S: Fedora 23
I don't know why it does that, but you can generate the text you want by replacing the space with a UTF non-breaking space and sending that to the stdin of convert and asking -label to read its text from the "file" called stdin:
printf "DYMO\xc2\xa0FONT" |
convert -background white -fill DarkRed -font DYMO -pointsize 72 label:#- result.png
Add -trim just before the output filename if you want the extraneous white space trimmed off from around the edges.
If you had more complicated text and didn't want to do that for all spaces, you could replace spaces using a short piece of Perl or sed to do it for you...
echo -n "Text with lots of spaces." | sed 's/ /\xC2\xA0/g' | convert -background white -fill DarkRed -font dymo -pointsize 72 label:#- -trim label.png
For almost 4 days I searched for a command how I could add a crop-mark to my image.
I have installed ImageMagick software as well. I tried so many commands but am not able to crop with adding proper gutter and a crop mark.
My image should look like this after the conversion:
https://alphagraphicslisle.files.wordpress.com/2011/12/gutter-2.png?w=540
Assuming you would know the dimensions of the crop area, you would use ImageMagick's Draw commands to add trim/crop lines.
If your source image does not have a bleed region, you can generate one with an Edge virtual pixel.
convert rose: -set option:distort:viewport 90x66-10-10 \
-virtual-pixel Edge -filter point -distort SRT 0 \
+repage rose_with_bleed.png
(Note: The rose: input image is a special name, using a built-in demo image that's present in every ImageMagick installation.)
Simplest/fastest way I can think of a solution would be to..
Draw trim-lead lines first
Composite image over lead
Draw crop rectangle over image
Example:
convert -size 110x86 xc:white \
-strokewidth 1 -stroke gray \
-draw 'line 20 0 20 86 line 90 0 90 86' \
-draw 'line 0 20 110 20 line 0 66 110 66' \
rose_with_bleed.png \
-geometry 90x66+10+10 -composite \
-stroke red -fill transparent \
-draw 'rectangle 20 20 90 66' \
out.png
I'm trying to convert a bunch of photos using imagemagick. However, I hadn't figured out how to overlay an image with gradient and write some text on it. I know the text part though:
convert IMG_8408.jpg \
-font URWChanceryMediumI \
-pointsize 250 \
-draw "gravity south
fill black text 0,40 'Some text stuff here'" \
test.jpg
Is there a way to add a white gradient to the bottom? Note, that the image size may vary.
What I have:
What I want:
I picked the colors so that it's clearly visible what I want to achieve
You can achieve desired output with 3 commands:
a. create the upper part of your image (a solid rectangle with your selected background color):
convert -size 640x200 xc:#A02B2B background.jpg
b. create another image containing the text over a gradient:
convert -size 640x110 gradient:#A02B2B-#126B27 -pointsize 25 -draw "gravity south fill black text 0,40 'Some text stuff here'" text.jpg
c. combine the images to obtain the final output:
montage background.jpg text.jpg -tile 1x2 -geometry +0+0 output.jpg
Note: I modified text creation parameters in step 2 to keep the command short, but you can add back your original settings
Use the following command:
magick -size 640x310 -define gradient:vector="0,107 0,0" gradient:"#a02b2b-#126b27" -flip -gravity south -font script-mt-bold -pointsize 48 -annotate +0+24 "Some text stuff here" output.png