views:

251

answers:

2

I am working on a website in which the client wishes to have users upload background images to a printable design, crop to size, add text. Do this to multiple pages then generate a pdf of the 'book'

I am running into the following issues/questions and just need to see where I can start

  • Are there any PHP developer packages that can do something similar. I have seen jquery crop tools but something also for adding text to an image?

  • How would I keep the resolution up? If the final cropped with text image needs to be 150dpi, when cropping I am guessing I would have them working on a 72dpi image, then somehow apply the crop and changes to the large image?

If the resolution issue wasn't a big deal I would go about it this way:

  • Simple image upload
  • Use jquery to crop photo to correct dimensions
  • Mess around with gdlibrary and imagettftext() to get the text onto an image (page)
  • Use something like FPDF to create a pdf from each 'page'

Is this the right way to go about it and any thoughts on the resolution issue. Thank you for any help!

A: 

domPDF is a good tool for converting HTML to a PDF. this way you can use the image they upload as a background image, then put the text over it in any standard HTML tag.

As far as the resolution/dpi issue goes, I'm not sure if there is much you can do outside of changing the size of the image. I would recommend looking into This PHP Library, which has a lot of good tools for manipulating images.

I think with a combination of these tools, you'll be able to create HTML that can make a PDF that's fit to print, and use that.

GSto
+1  A: 

Your primary tool should be ImageMagick. ImageMagick can do the cropping, resizing, scaling, overlay text or graphics, combining images, and apply special effects. A big advantage of using a separate tool instead of PHP's image manipulation tools is that you can do the same transforms in batch through other mechanisms, or even hand the work over to another server to keep the website more responsive. And if you do want to integrate it tightly into the website, you can use the MagickWand For PHP interface.

Cropping does not change DPI, only the dimensions of the image. Scaling, on the other hand, changed both.

You should take a look at Gallery, a GPLed program with some of the functionality you're looking for, and written in PHP.

dj_segfault
My main concern is that I will probably want to have the user crop, so while it technically wouldn't size the photo, I would want to resize it beforehand to make it easy for them to work with, then I would have to somehow translate the cropping dimensions from the 72dpi to the printable. Or is the the wrong way to go about it?
kilrizzy
I understand now. You want them to visually specify where to crop, but not crop the image they see, but the larger/higher res one stored on the server. Going by percentages MAY be accurate enough, depending on the difference in pixels between the on-screen one and the on-server one. Just make sure you use floating point math.
dj_segfault
Also check out http://www.picnik.com/ for a complex online photo editing software example.
dj_segfault