Jump to content

Recommended Posts

Here is the code I have right now:

<?php
header('Content-type: image/png');

$grey = new ImagickPixel('#ebebeb');
$orange = new ImagickPixel('#0f92d6');

$image = new Imagick('assets/lop.png');
$layer = new Imagick('assets/lop-base.png');
$layer->thumbnailImage(200, 0);
$image->thumbnailImage(200, 0);

$layer->paintOpaqueImage($grey, $orange, 100);

// Place layer on image
$image->compositeImage($layer, Imagick::COMPOSITE_SOFTLIGHT, 0, 0);

// Let's merge all layers (it is not mandatory).
$image->flattenImages();

echo $image;

?>

It's putting the layers on top of eachother very nice. The thing is is that this involves some heavy shading at times depending on the bunny breeds.

 

Here is what the base image ($image) looks like:

 

pEJNizR.png

 

And here is what the overlay ($layer) looks like:

 

qvoPPYn.png

 

This is what the outcome looks like versus the intended result:

 

9HTEfAr.png Qi0peGI.png

 

I've tried almost all of their composite constants.. I can't figure out how to do this or the best way of going about it. Because the colors are going to be dynamic throughout the site so I can't just save a .png of every color combination.. and there will be more colors layered on top of eachother like markings/patterns/etc.

 

Thanks for any help!

Link to comment
https://forums.phpfreaks.com/topic/291208-imagemagick-layer-overlay/
Share on other sites

Add $_GET parameters to your url for your script so you can control any colors or shading strengths.

 

As an example I'll show you my website snapshots using parameters and GD instead

 

http://dynaindex.com/url-thumb.php?size=250&text=Dynaindex.com&textsize=8&textcolor=aqua&url=phpfreaks.com

Edited by QuickOldCar

Because the colors are going to be dynamic throughout the site so I can't just save a .png of every color combination

The idea would be to show images using your own script and setting values the way you need them to appear.

I was showing how url parameters can manipulate the generated image.

 

So your issue is how to make the bunny colors change without darkening the lighter sections as well?

 

I believe you have to use a grayscale image and -modulate

http://www.imagemagick.org/Usage/photos/#chroma_key

Look at the shirt image examples

 

You can also look at replace and fuzz

 

 

To better explain using a single script using GET parameters

 

you would post this image code and change the values wherever needed it.

<img src="imagemagick.php?shading=10&color=blue"/>

And in your php script making variables for each

if(isset($_GET['shading']) && ctype_digit($_GET['shading'])){
$shading = $_GET['shading'];
}else(
$shading = "0";
}

if(isset($_GET['color']) && trim($_GET['color']) !=''){
$color = trim($_GET['color']);
}else(
$color = "white";
}
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.