Jump to content


GD Image functions

  • Please log in to reply
1 reply to this topic

#1 TecBrat

  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 25 October 2006 - 12:59 PM

I have just become aware of how to maniputlate images with php imagecreate and imagemerge functions. I am considering a fairly ambitions (for me) script to build a business card online. The printing process requires a safe-zone around the image to allow for cutting. I what I want is suggestions on how to proceed. Particularly, how to avoid any pitfalls I might not see coming that someone else might. My artist will deal with RGB to CMYK conversion.

I need to start by uploading a background of 1125x675
I then need to crop (not resize) this image to 975x525 //to display without the cutaway safezone. A 75 pixel cut from each of 4 sides.
I need to make a thumbnail of the cropped image at half size, 488x263
I need to allow, but not require, a logo to be uploaded. If uploaded, it must be at least 200x200
I need to make a thumbnail of the logo, half size. for display.
I plan on allowing the client to select the location of the logo by entering 2 numbers from 0 to 100 where 0 puts the logo top left, and 100 puts the logo off of the image to the right bottom. (that means that about 90,90 is the highest that is likely to be used. I already have the math for this worked out for display purposes.)
I need to allow TTF fonts to be selected and text to be created and positioned in similar fashion to the logo.
After each adjustment, the thumbnail is re-displayed.
Once the adjustments are made, the script will take the TTF text info, logo info, and adjustment info and merge the text and full size logo onto the full size background, perhaps with an intermediate step of merging onto the 975x525 image because it's ratios are the same as the working thumbs. I will then save the created image and send an email to our art dept that the process is complete, an provide the image filename, made unique by use of the unix timestamp.

Not asking anyone to code it for me, but a good push in the right direction would be appreciated. Has someone already done something like this and noticed something I left out?
Thanks, TecBrat.
It's kinda lame at the moment, but...
PHP MySQL Playground

#2 xsist10

  • Members
  • PipPipPip
  • Advanced Member
  • 114 posts

Posted 25 October 2006 - 02:26 PM

Use this for cropping:

bool imagecopy ( resource dst_im, resource src_im, int dst_x, int dst_y, int src_x, int src_y, int src_w, int src_h )
Copy a part of src_im onto dst_im starting at the x,y coordinates src_x, src_y with a width of src_w and a height of src_h. The portion defined will be copied onto the x,y coordinates, dst_x and dst_y.
(from http://www.php.net/m...n.imagecopy.php)

Use this for resizing:

bool imagecopyresized ( resource dst_image, resource src_image, int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h )
(from http://www.php.net/m...copyresized.php)

Use this for TT fonts:

array imagettftext ( resource image, float size, float angle, int x, int y, int color, string fontfile, string text )
(from http://www.php.net/m...magettftext.php)
SA PHP Archives - www.phparchives.za.org

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users