Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using PHP to recreate something similar to VistaPrint / CafePress / Zazzle. Any Ideas?

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!

like image 526
kilrizzy Avatar asked Feb 23 '10 19:02

kilrizzy


2 Answers

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.

like image 199
dj_segfault Avatar answered Oct 19 '22 22:10

dj_segfault


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.

like image 42
GSto Avatar answered Oct 19 '22 23:10

GSto