Page 1 of 1

Problem while applying Borders.

Posted: 2013-06-21T16:15:45-07:00
by helloworld
In our system we allow customers to upload "border images in .png formats" like below.

Please find the images of three borders which we allow customers to upload in our system.

http://f.cl.ly/items/0G1l3Z1c2A0w1r290C3I/keyline.png
http://f.cl.ly/items/0X3u3e3F0D1s1v3g2u0K/black.png
http://f.cl.ly/items/3C0C1G3S253J3p3y3X2M/art.png


So what i am trying to do is, trying to insert the below image in the above three borders.

http://f.cl.ly/items/0g0p0x1V1L083E3E0745/1.jpg


And you guys gave me a command for that, First i should convert the image to the desired pixels and next i have to convert the border to the desired pixels and composite both border and image to the center ,

" convert \( 1.jpg -resize "500x500" -write 1k.jpg \) \( WH.png -resize "500x500" -write WH1.png \) -gravity center -composite fi.jpg"

http://f.cl.ly/items/0g0p0x1V1L083E3E0745/1.jpg
http://f.cl.ly/items/0m3b1E3B0r1B3F3D2S1r/1k.jpg
http://f.cl.ly/items/1Y2d2y2B1G291J1p2q0B/WH.png
http://f.cl.ly/items/2M2q2S2a0i1Q0p0G2q3H/WH1.png
http://f.cl.ly/items/253Q2F3u3P1R1Q44143J/fi.jpg


So in the final fi.jpg there is some portion of the image at the 4 corners is covered by the border WH1.png.

But i am expecting the final image should be surrounded by border but not border on the image.

Re: Problem while applying Borders.

Posted: 2013-06-21T16:53:33-07:00
by snibgo
Windows script:

Code: Select all

convert ^
  art.png -resize 237x238%% ^
  1.jpg ^
  -gravity center -composite ^
  fi2.jpg

Re: Problem while applying Borders.

Posted: 2013-06-23T08:58:44-07:00
by helloworld
I am not familiar with Windows script, Can you tell the Bash script or Linux command?

Re: Problem while applying Borders.

Posted: 2013-06-23T08:59:52-07:00
by helloworld
I have the border X Y W and H values like this {"x":40,"y":26,"w":519,"h":347}

Re: Problem while applying Borders.

Posted: 2013-06-23T09:14:11-07:00
by snibgo

Code: Select all

convert \
  art.png -resize 237x238% \
  1.jpg \
  -gravity center -composite \
  fi2.jpg

Re: Problem while applying Borders.

Posted: 2013-06-23T10:22:19-07:00
by helloworld
I did not understand this, But i can explain you more clearly on what i exactly want.

I am looking for a Linux Command where i can fit my own border to an image. Right now, we have 5 predefined borders in our system like Art, Gallery, Black, Reverse Keyline, White and Keyline. below are those links for those border images.
So i want to fit the below image in those 5 pre-defined border according to the re-sizing size,

http://f.cl.ly/items/0g0p0x1V1L083E3E0745/1.jpg

You guys already gave me a command for this, what you said is first re-size the Image and then re-size the Border and then place image at the -gravity center -composite .

But if i do in this way, I am missing four sides of the image. I mean border is coming on the top the image and covering four sides of the image but what i want is, image should be surrounded by the border but not border on image.

Re: Problem while applying Borders.

Posted: 2013-06-23T10:33:03-07:00
by glennrp
You must resize the image to the dimensions of the hole in the border instead of to the full dimensions of the border. You will need to keep track of the inside dimensions of your 5 borders in order to do that.

Re: Problem while applying Borders.

Posted: 2013-06-23T10:50:26-07:00
by snibgo
Instead of resizing the image (1.jpg) to fit the border (art.png), my command resizes the border to refit the image.

I calculated that the border width should be increased by 237%, and height by 238%. How did I calculate this?

art.png is 600 pixels width, with left and right margins 47 pixels. It is 400 high, with top and bottom margins 32.
600-47-47 = 506
400-32-32 = 336

So the inside of the frame is 506x336. We need this to match 1.jpg, which is 1200x800.

1200/506 = 2.371541501976285, 237%
800/336 = 2.380952380952381, 238%.

Re: Problem while applying Borders.

Posted: 2013-06-23T17:05:40-07:00
by helloworld
I will try and get back to you if i have any issues.