Help needed - php JSQuery and Imagemagick

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
butchx5
Posts: 1
Joined: 2011-11-05T04:13:52-07:00
Authentication code: 8675308

Help needed - php JSQuery and Imagemagick

Post by butchx5 »

Hi all
I know this is a real imposition but I didn't know what else to do - so hope you will forgive me.

I have a challenge for you as I have no hair left and my family cannot cope with my frustration any longer.

I am not a programmer just someone who has never had enough money to pay for what I need and have always self-taught along the way and normally I get there in the end. I am setting up a business that I can do at home due to disabilities preventing me from getting out for work. From all I have read and tutorials, etc I am pretty sure my idea is feasible but it is totally evading me at present. And even when I have discovered the correct coding I don't know how to incorporate it into my website.

I am creating a site to sell skins for a variety of devices and rather than have to create, save, upload an image for every combination I have the idea of using php and imagemagick to create the required images as and when that combination is chosen - see skinit.com for a better working example.That way expanding the designs and devices should be a lot easier for me as in theory I wold only need to upload the new design image and the new device template image.

So there will be:
Design images with various sort categories and sub categories
Device template images with various sort categories and sub categories

Look forward to reading your thoughts.

Helen

LAPTOP IMAGE: http://img.auctiva.com/imgdata/1/5/6/6/ ... 8749_o.gif
SKIN IMAGE: http://img.auctiva.com/imgdata/1/5/6/6/ ... 8120_o.jpg
SKINNED LAPTOP IMAGE: http://img.auctiva.com/imgdata/1/5/6/6/ ... 8759_o.jpg
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Help needed - php JSQuery and Imagemagick

Post by Bonzo »

I can be done but needs some fine tuning and optimising. I have left it in steps with tempory images so you can see what is happening at each stage. Members with more skill will probably see better ways to do things :)

I would modify the images on upload - server space is cheap and extra processing is not.

Anyway a rough piece of code:

Code: Select all

<?php

// Show the area to cover
exec("convert 520208749_o.gif -stroke red -strokewidth 1 -fill none -draw \"polygon 34,35 371,9 484,221 121,295 \" original.gif");

// Distort the skin image
exec("convert 520208120_o.jpg -resize 500x -matte -virtual-pixel transparent -distort Perspective \"0,0 38,25 0,267 105,222 400,267 395,170 400,0 305,0 \" distort.png");

// Put the distorted skin onto the original
exec("convert 520208749_o.gif distort.png -gravity center -geometry -0-0 -composite output.png");

// Rotate the skinned image so the back is level
exec("convert output.png -background none -rotate 14 -trim rotate.png");

// Create a mirror image of the skinned image and make it gray
exec("convert rotate.png -flip -fill white -colorize 50% temp.png");

// Join the two images to gether
exec("convert rotate.png temp.png -append append.png");

// Rotate the image back again and crop it 
exec("convert append.png -background none -rotate -14 +repage -crop 680x480+0+0 -trim final.gif");
?>

<img src="original.gif">
<img src="distort.png">
<img src="output.png">
<img src="rotate.png">
<img src="temp.png">
<img src="append.png">
<img src="final.gif">
Post Reply