How can I create an Image using Imagemagick in which I stick for example 6 images next to each other, thus the background shall be transparent(.png file).
It shall look something like this: ( The black rectangles shall represent images )
How do I achieve this ?
Edit (Update)
So far I have done this image:
using this command:
montage img1.jpg img2.jpg img3.jpg img4.jpg img5.jpg img6.jpg -geometry +10+10 -resize 720x480 output.jpg
but I am not sure how to proceed further.
You are almost there! Take your montage command and output the resulting 3x2 montage to stdout as a PNG into a new convert which appends it below your top.jpg image:
montage im*jpg -geometry +10+10 png:- | convert -gravity north top.jpg png:- -append result.png
If you are on Windows, you probably need:
montage *.jpg ...
or you can type it out in full:
montage img1.jpg img2.jpg img3.jpg img4.jpg img5.jpg img6.jpg -geometry +10+10 png:- | convert -gravity north top.jpg png:- -append result.png
This is just another way of doing this. I think it may be a little simpler than Mark's solution. Note the parentheses that groups commands into single image ouput. Also remember that IM requires space before and after the openining brackets.
magick -gravity center -background none -bordercolor none ( f1.jpg -border 10 ) ( f2.jpg f3.jpg f4.jpg -border 10 +append ) ( f5.jpg f6.jpg f7.jpg -border 10 +append ) -append output.png
More on appending is here however in most cases I prefer montage command.
Related
How to use an external command to make an edit of pic in the gimp and then return the result to the stage in a plugin or script.
Example in shell script.:
magick label.gif +matte
( +clone -shade 110x90 -normalize -negate +clone -compose Plus -composite )
( -clone 0 -shade 110x50 -normalize -channel BG -fx 0 +channel -matte )
-delete 0 +swap -compose Multiply -
The command above (imagemagick app) create a gif and i want put back in gimp stage. May be other simple option or application, but i need of return the edited back to gimp. Python, script fu? Thanks so much.
enter image description here
There is a shellout.py Gimp plugin floating around from which you can borrow code. Typically:
you export the layer to a temp file (if you work on the whole image, you likely have to do a pdb.gimp_layer_new_from_visible())
call the executable with subprocess.Popen() and a list of arguments
load the result as a new layer with pdb.gimp_file_load_layer()
If GIMP will take stdin, then pipe from ImageMagick to GIMP using the GIMP XCF file format.
magick label.gif +matte
( +clone -shade 110x90 -normalize -negate +clone -compose Plus -composite )
( -clone 0 -shade 110x50 -normalize -channel BG -fx 0 +channel -matte )
-delete 0 +swap -compose Multiply XCF:- | GIMP -
I need to dynamically create an image, and I'm trying to find a good 'starting place' using magick or convert from command line (the actual library I will convert the CLI command to is MiniMagick for ruby)
To be honest, it's a little bit overwhelming... I'm not asking someone to write the whole thing for me, just get me a good 'starting' place that I can then work on adding text "layers" to.
Here is what the final output image needs to look like, and the required things I'm looking for:
A background image (the gray circle) that I can position using x,y coordinates. The input file is circle.png. I'd also like to be able to enlarge/reduce the dimensions of the circle to be the exact size i want.
Red small, centered text.
Bold, larger, centered black text. For this text it needs to intelligently go on new lines when the line is too long (and have padding against the outside of the image so it doesn't touch the edge)
Blue, underlined, medium text thats centered.
A red border that overlays the background image
circle.png for reference
This will get you a start using ImageMagick to create your image. Unix syntax. ImageMagick does not have an underline feature. So you need to select an underline font for that section. (However, there are slightly more complex ways to achieve that using label: and then splicing in the underline)
convert -size 299x249 xc:white \( circle.png -resize 200x200 \) \
-gravity northwest -geometry +100+70 -compose over -composite \
-bordercolor red -border 1 \
-font arial -fill red -pointsize 18 -gravity north -annotate +0+20 "**Info**" \
-font arial -fill blue -pointsize 28 -gravity south -annotate +0+50 "click here" \
\( -size 279x -background none -fill black \
-font arial -pointsize 28 -gravity center \
caption:"Welcome John to your profile, have a look around" -trim +repage \) \
-gravity center -geometry +0-20 -compose over -composite \
result.png
NOTE: updated slightly
In my folder i have 4 pics every time in a 4X6 pic size.
In next step i want to show all the 4 pic's into different cobinations to user like, {pics: 1 2 3 4}
image 1: 1+2;
image2: 1+2+3;
image3: 2;
image4: 1+2+3+4;
how do i can achive this...in .net/any technology please suggest.
You can do it like this with ImageMagick which is installed on most Linux distros and is available for OSX, and Windows. At the command-line, in Terminal, side by side:
convert a.png b.png +append result.png
Or, above and below:
convert a.png b.png -append result.png
Or, 4-up:
convert a.png b.png +append \( c.png d.png +append \) -append result.png
Or 4-across:
convert a.png b.png c.png d.png +append result.png
If your images are JPEG, just change the extensions. If you are on Windows, you may need to put carets (^) in front of the \ or ( to escape them.
I'm using ImageMagick service to pre-process the receipt image before using tesseract-OCR engine to extract texts. I need to remove the background of the receipts. I've gone through masking to remove the border here. But I'm unable to create the mask for the receipts.
However, I've tried to remove shadows from the receipt images.
Initial Image (Example receipt)
convert input.png -colorspace gray \
\( +clone -blur 0x2 \) +swap -compose divide -composite \
-linear-stretch 5%x0% photocopy.png
After the code is applied:
I've tried the code below to make all colors except white to black but this does not seem to be totally blacking out the background of photocopy.png.
convert receipt.jpg -fill black -fuzz 20% +opaque "#ffffff" black_border.jpg
Is there any way to remove the border of the receipt image? Or create any kind of masks out of the image? Note: I need to remove noise and border for multiple images with different backgrounds.
To answer your question
"Is there any way to remove the border of the receipt image? Or create any kind of masks out of the image?"
The following command (based on your own code) will create an image which you can use to derive the dimensions of an applicable mask:
convert \
origscan.jpg \
-colorspace gray \
\( +clone 0 -blur 0x2 \) \
+swap \
-compose divide \
-composite \
-linear-stretch 5%x0% \
-threshold 5% \
-trim \
mask-image.png
You can use that mask-image to create a monochrome (black) mask -- in one command:
convert \
origscan.jpg \
-colorspace gray \
\( +clone 0 -blur 0x2 \) \
+swap \
-compose divide \
-composite \
-linear-stretch 5%x0% \
-threshold 5% \
\( \
-clone 0 \
-fill '#000000' \
-colorize 100 \
\) \
-delete 0 \
black-mask.png
Here are the results of above two commands, side by side:
You can use identify to get the geometry of mask-image.png as well as black-mask.png:
identify -format "%g\n" *mask*.png
2322x4128+366+144
2322x4128+366+144
So the image canvases are 2322 pixels wide and 4128 pixels high. The visible parts both images are of course smaller, following our -trim operation. (The +366+144 part indicates a horizontal/vertical offset from the top left corner of the original image.)
Additional comment: Having said all this: you should really look into creating better photos from your receipts! (If you have a camera which can create images of 4128 pixels height this shouldn't be a problem. If you have so many receipts to process as you say, then it may be a good idea to acquire a small platten glass that you can place on top of the paper in order to have it straightened out while photographing...)
If using ImageMagick on a unix-like system, you could try my text cleaner script.
textcleaner -f 20 -o 10 -e normalize UhSV6.jpg result.jpg
I am trying to do the same as described here http://www.imagemagick.org/Usage/advanced/#reflections
I am using imagemagick on windows and the command I am using is like this -
convert test3.jpg -alpha on -virtual-pixel transparent -clone 0 +distort Perspective "0,0,100,50 0,394,100,344 300,394,300,394 394,0,394,0" -clone 0 -channel A -evaluate multiply .35 +channel +distort Perspective "0,0,100,-50 0,394,100,344 300,394,300,394 394,0,394,0" -delete 0 +swap -background none -layers merge +filter -size "594x500^!" xc:none +swap -gravity North -geometry +0+5 -composite reflect_distort_new.jpg
The actual image is
The result I am getting is like this -
I was wondering if any one can help me fixing the following issues -
I want to add a reflection as explained in the example, but it does not appear with my command line. I have removed parenthesis from the -clone command as it was giving error on windows.
How to remove the black background being added there?
How to apply antialising as there are edges on the resultant image.
Ah Well, after trying 1000+ times, I got it correct -
convert magCover1.png -alpha on -virtual-pixel transparent ^
( +clone -flip -channel A -evaluate multiply .35 +channel ) -append ^
+distort Perspective "0,0,200,100 0,788,200,788 600,788,600,850 788,0,740,50" ^
-gravity North -crop "1094x1000+0-5^!" ^
-background none -compose Over -flatten -transparent white reflect_distort.png
I get the following result -