How to generate a custom image in php? - php

I am looking to create a Product customization tool in PHP. This tool will allow the user to create his own Customization to a predefined Mobile cover. I already have a Mobile cover image and I am looking to allow a user to write 3 characters which will be written in a circle called as monogram with a background color.
I am not sure how to proceed ahead with it. I am looking to dynamically create image that is placed on the Mobile cover in such way that it looks its part.
here is a link to sample image which would be generated
http://d13eowy7ljcd3.cloudfront.net/images/ark.png
I am looking for way on how to approach it and which php image handling libraries should I make use of.
Help would be greatly appreciated.

Have a look at GD and Image Functions. imagearc
There are a lot of examples out there.
You may also have a look at ImageMagick and GraphicsMagick.

Related

How to create Image with custom text in php?

I am looking to create a Product customization tool in PHP. This tool will allow the user to create his own Customization to a predefined Mobile cover. I already have a Mobile cover image and I am looking to allow a user to write 3 characters which will be written in a circle called as monogram with a background color.
I am not sure how to proceed ahead with it. I am looking to dynamically create image that is placed on the Mobile cover in such way that it looks its part.
here is the link to a sample image which would be generated
http://d13eowy7ljcd3.cloudfront.net/images/ark.png
I am looking for way on how to approach it and which php image handling libraries should I make use of.
I think you should use ImageMagick: http://php.net/manual/en/book.imagick.php This need that imagemagick was installed on the system, If you do not have a dedicated server you could try with GD http://es1.php.net/manual/en/book.image.php, but I think that imagemagick is more powerfull.

How to color some parts of the image programmatically?

I have an Italian map, and I need to color some regions programmatically.
This is the image:
As you can see there are few regions with a different color (orange).
I have a page where I need to highlight the areas of user, so I need to color those areas differently. The base is grey and the selected must be orange.
Now, How could I do it programmatically?
I would like to avoid creating one image for each user.
Any Ideas?
I still prefer creating "one image per user". It's actually not per user. Make your variations of the image already created, and load them by your server-side logic. I mean, something like sprites. Have every part both colorized and non-colorized.
Have you considered jQuery powered interactive maps like this one:
Link 1
Alternatively, if you get really stuck you could look at something like this (paid plugin!)
Link 2
I don't think php's GD or imagick libraries are so powerful, and if so, it won't be that easy to do, and the resulting image could lose quite a lot of quality, as the borders of the map are even antialiased.
I would suggest you to Google for "interactive maps", normally you have the vectorized images and use Javascript and CSS to achieve what you are trying to do. Maybe there are already something for Italy.

Suggest a good image upload-and-crop tool

I'd like to know which up-and-crop tools you suggest to me. I tried couple of scripts like JCrop but I always get stack with some type of format like bmp. I either can't upload or I can upload but can't crop. If you use (or know) one that works well with different formats, then please just give me its name and I'll be strongly appreciated!
Well, i dont know much about JCrop but you can build it up with several tools.
I think image processing kind of works should be done on server side.
There is a good OOP Library called Imagine. It's mostly based on Python's Imaging Library which is awesome and has decent documentation. And this is its crop functions documentation.
On client side you can use some kind of image area selection tool to let the user determine desired area to crop. imgAreaSelect is good to go. Then you can send crop area to php by JQuery's post function or any other way.
It's amassing that in all this time this haven't got any other answers, I hope this helps.
Like stated in the other answer you should combine a few tools to solve each part of the problem.
To let the user select the cropping area:
If you don't like jCrop you can try Guillotine. It's very lightweight, easy to set up and allows to crop, zoom and rotate images. It has touch support and it's responsive (fluid).
Keep in mind that you can't display image types that the browser doesn't support, but you can convert them in step 3.
To upload the images:
For most cases, once you have the cropping area, with a simple file input will suffice.
Now, if you want to upload files asynchronously check out
this
for a quick and easy set up or this
for a more complex solution.
To actually crop and process the image:
Once uploaded you can crop, convert and process the images on the server, ImageMagick is a great tool for this. It's Open Source and many languages have wrappers for it.
You've tagged the question with PHP so here is a PHP wrapper for ImageMagick.

Programmatically create image from web-page or a single DIV

Is there any way to programmatically create (client or server side (PHP)) a image from a specific DIV or a complete (web) page? I'm currently creating a web-site for free coupons and the idea is when the end-user clicks on the "Print" button, the app opens a new tab/window with all the selected coupons as a single image (JPG, PNG or etc..) in A4 format ready for printing. Each coupons has it's own data (Article name, price, description etc..) so I need it to be done programmatically over a coupon-template I designed.
I do not ask you to write code for me, just to suggest a solution I could use/develop. If not already exist, I will upload/publish it for free :)
Update: I did it with the PHP GD library :) Still not satisfied with the idea to use Images instead of PDF, because each printing results with different Coupon sizes (images) on different PC's. That's why PDF may would be a better solution. You can see/test it on demo.svikuponi.ba - Just select a few Coupons and click the PRINTAJ button above.
You cannot create image from div for sure but yes you can create dynamic images in php using its gd library.
Following links will help:
http://php.net/manual/en/function.imagecreate.php
http://phptutorial.info/learn/create_images/
Here is a great way for you to create images on the client side: http://smus.com/screen-capture-for-chrome-os
You can take this and create a web app that will work nicely on webkit (for other browsers - I'll look at JS polyfills).
Did anyone mention html2canvas and/or jsfeedback ?
It create a page screenshot completely in javascript, then you can send to the server via ajax..
Obviously, CSS support lack some things.
In php, there is many image related functions like imagettftext() in GD library
for details, check this out http://php.net/manual/en/book.image.php
if GD is not enough, you can try imagick as well
for the template, you can try creating a true color handle in php from your file(image) and add the text part or something else with all kinds of effects and bar codes etc.
but in your case, i would suggest dynamic PDF creation since it would better with formatting instead of plain image, the pdf lib :
http://www.fpdf.org/
you could easily have a background image of your token/voucher and overlay the text using some php variables.
i believe it is possible to create a unique bar-code with php imaging too.
It is possible to get a screenshot from a webpage, but this is quite a hassle. You need to start a webbrowser to render the page and get a screenshot from that.
You are probably better of by parsing some specification and feeding it to a couple of GD or Imagick functions. This is less versatile, but easier to manage.

how to create a system where store admin can upload images that would appear on a shirt/mannequin

i have been tasked with creating an ecommerce site. the store admin needs to be able to upload images, which would populate on a shirt/mannequin. basically there will be new shirt designs added regularly and they dont want to create a shirt to take an image of and put on a mannequin each time.
at first thought.. i was thinking the store admin would just generate a specific sized transparent png.. that would overlay a blank mannequin but i wonder if there is an easier approach.. maybe with some sort of php image functions?
any pointers would be great!
ps. i am mainly a php / mysql developer so this is what i plan on using.
Sounds like you have the right approach. That's how I would implement. If you use image magic or something like that, it will use a lot of resources just to merge two images when you can create a transparent .png and use css to overlay it on the shirt.

Categories