Jump to content

GD Image functions


TecBrat

Recommended Posts

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.
Link to comment
Share on other sites

[b]Use this for cropping:[/b]

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 [url=http://www.php.net/manual/en/function.imagecopy.php]http://www.php.net/manual/en/function.imagecopy.php[/url])

[b]Use this for resizing:[/b]

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 [url=http://www.php.net/manual/en/function.imagecopyresized.php]http://www.php.net/manual/en/function.imagecopyresized.php[/url])


[b]Use this for TT fonts:[/b]

array imagettftext ( resource image, float size, float angle, int x, int y, int color, string fontfile, string text )
(from [url=http://www.php.net/manual/en/function.imagettftext.php]http://www.php.net/manual/en/function.imagettftext.php[/url])
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.