Page 1 of 1

PAID: trim edges and merge 2 PNG into a layout

Posted: 2020-01-31T04:51:08-07:00
by jpcpizo
Hello, I need a command line / script to trim the edges of 2 PNG images, and fit both of then into a new PNG.

The new PNG should be the size of 68mm (H) x 200 mm (W) and 400 DPI.

Both images should are designs that I will use in mug production later, so each one could not be bigger than 68mm (H) x 68mm (W).

Here is an example of what I need:

1. I have those 2 png images:
Image
https://imgur.com/Z252eM6

and

Image
http://imgur.com/3UzaF3w

and they need to be trimmed and fitted into a single PNG like that:

Image
http://imgur.com/V0jh7FC

The image above, the fist design is 68x68mm in size, as the limiting dimension was the height. But the second image is 68x53mm as the limiting dimension was the weight.

I'm a newbie using image magick, so i preatty much don't know how to properly use this tool.

Thank you in advance!

Joao

Re: PAID: trim edges and merge 2 PNG into a layout

Posted: 2020-01-31T13:06:06-07:00
by fmw42
ImageMagick does not work in units of mm. It works in pixels. So you have to convert your mm dimensions to pixels using your density.

Your desired dimensions are 200x68 mm (WxH). The conversion is:

400 dpi * 200 mm / 25.4 mm per in
and
400 dpi * 68 mm / 25.4 mm per in

or

400*200/25.4 = 3150 px
and
400*68/25.4 = 1071 px

So the command would be in Unix syntax on ImageMagick 6:

Code: Select all

convert -size 3150x1071 xc:none \
\( left.png -trim +repage -resize 1071x1071 \) -gravity west -composite \
\( right.png -trim +repage -resize 1071x1071 \) -gravity east -composite \
left_right_banner.png
Image

If using Imagmagick 7, change convert to magick

Please always provide your ImageMagick version and platform/OS when asking questions here, since syntax may vary.

Re: PAID: trim edges and merge 2 PNG into a layout

Posted: 2020-02-02T17:07:13-07:00
by jpcpizo
Hello, I'm using imagemagick 7.0 and windows 10.

I belive the sintax it's a little different right?

thank you in advance.

Re: PAID: trim edges and merge 2 PNG into a layout

Posted: 2020-02-02T22:10:38-07:00
by fmw42
On Windows and IM 7 it would be

Code: Select all

magick -size 3150x1071 xc:none ^
( left.png -trim +repage -resize 1071x1071 ) -gravity west -composite ^
( right.png -trim +repage -resize 1071x1071 ) -gravity east -composite %
left_right_banner.png

Re: PAID: trim edges and merge 2 PNG into a layout

Posted: 2020-02-03T16:07:39-07:00
by jpcpizo
Yes! that's it. Worked Perfectly, thank you alot.

Should I pay you? please DM me.

Re: PAID: trim edges and merge 2 PNG into a layout

Posted: 2020-02-03T17:00:50-07:00
by fmw42
No, not necessary.