PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 14th, 2011, 02:36 PM
Myztacia Myztacia is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Location: Minnesota, USA
Posts: 96 Myztacia User rank is Lance Corporal (50 - 100 Reputation Level)Myztacia User rank is Lance Corporal (50 - 100 Reputation Level)Myztacia User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Day 3 h 20 m 42 sec
Reputation Power: 9
PHP5 - MagickWand Opacity issue

I have a script that essentially builds a picture of a cat. All images are .png files.

A user can choose the base color, then add markings to the cat. They can also set colors for the markings. The outline is then layered on.

The problem I'm running into is I would like to remove some opacity from the markings. Currently, the person can change the color of the marking, then layer it onto the base. BUT, I would like that marking to be able to fade by a percentage the user chooses.

I tried to use MagickSetImageOpacity() for this, however, it ended up changing the opacity of the ENTIRE image instead of the area that wasn't already transparent.

I'm pretty sure this is the wrong function to use. The only solution I can really think of is iterating through the index or pixels and changing the transparency that way (I've never done that, so that's just a theory). This sounds like a HUGE waste of server resources, though.

I have attached a base, outline, and marking. I have also attached one completed image WITHOUT setting opacity, and a screenshot of the form where I attempted to set the opacity on the Giraffe marking.

As you can see, the Giraffe marking became a solid color and obliterated any layers below it.

To reiterate, it SHOULD have instead set the opacity of any colored pixels to 10% of what they were. The background transparency should have been left alone.

Sorry if this is confusing; ask any questions and I'll try to clear things up!
Attached Images
File Type: png outline.bak.png (25.0 KB, 34 views)
File Type: png base.png (6.7 KB, 34 views)
File Type: png gradient.png (26.2 KB, 36 views)
File Type: png 303802.png (156.1 KB, 37 views)
File Type: png Untitled-1.png (41.8 KB, 35 views)

Reply With Quote
  #2  
Old June 14th, 2011, 05:40 PM
requinix's Avatar
requinix requinix is offline
Still alive
Dev Shed God 16th Plane (12500 - 12999 posts)
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,869 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 5 Days 6 h 19 m 22 sec
Reputation Power: 8977
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
You lost me in there, but I think you're saying that you want one part of an image made transparent and another not?
What about using two images: one for the markings (you change this one's transparency) and the other for the not-markings.

Reply With Quote
  #3  
Old June 14th, 2011, 06:32 PM
Myztacia Myztacia is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Location: Minnesota, USA
Posts: 96 Myztacia User rank is Lance Corporal (50 - 100 Reputation Level)Myztacia User rank is Lance Corporal (50 - 100 Reputation Level)Myztacia User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Day 3 h 20 m 42 sec
Reputation Power: 9
Not quite.

The marking is already transparent to a point: the background of it is transparent, with the content inside it being either opaque or translucent. I want to change the content's transparency so less of it shows (ie, I want the marking to become lighter when it is layered onto the base).

This will allow players to have more subtle markings that, when layered with other markings, will allow multiple markings to display.

Reply With Quote
  #4  
Old June 17th, 2011, 10:23 PM
Myztacia Myztacia is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Location: Minnesota, USA
Posts: 96 Myztacia User rank is Lance Corporal (50 - 100 Reputation Level)Myztacia User rank is Lance Corporal (50 - 100 Reputation Level)Myztacia User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Day 3 h 20 m 42 sec
Reputation Power: 9
Any insight, anyone...?

Reply With Quote
  #5  
Old June 18th, 2011, 03:27 AM
kicken's Avatar
kicken kicken is offline
Wiser? Not exactly.
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: May 2001
Location: Bonita Springs, FL
Posts: 5,654 kicken User rank is General 37th Grade (Above 100000 Reputation Level)kicken User rank is General 37th Grade (Above 100000 Reputation Level)kicken User rank is General 37th Grade (Above 100000 Reputation Level)kicken User rank is General 37th Grade (Above 100000 Reputation Level)kicken User rank is General 37th Grade (Above 100000 Reputation Level)kicken User rank is General 37th Grade (Above 100000 Reputation Level)kicken User rank is General 37th Grade (Above 100000 Reputation Level)kicken User rank is General 37th Grade (Above 100000 Reputation Level)kicken User rank is General 37th Grade (Above 100000 Reputation Level)kicken User rank is General 37th Grade (Above 100000 Reputation Level)kicken User rank is General 37th Grade (Above 100000 Reputation Level)kicken User rank is General 37th Grade (Above 100000 Reputation Level)kicken User rank is General 37th Grade (Above 100000 Reputation Level)kicken User rank is General 37th Grade (Above 100000 Reputation Level)kicken User rank is General 37th Grade (Above 100000 Reputation Level)kicken User rank is General 37th Grade (Above 100000 Reputation Level)  Folding Points: 2670569 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2670569 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2670569 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2670569 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2670569 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2670569 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2670569 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2670569 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2670569 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2670569 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 2 Months 2 Weeks 2 Days 5 h 1 m 44 sec
Reputation Power: 3436
I don't know the magick functions, but it sounds like your looking for the equivalent of the GD function imagecopymerge function, particularly for the pct parameter which allows you to copy an image at a specified opacity level.

Browsing the docs on php.net for a bit, sounds like the following might be close:
PHP Code:
 $base = new Imagick('base.png');
$marks = new Imagick('marks.png');
$marks->SetOpacity(0.25);
$base->compositeImage($marksimagick::COMPOSITE_COPY|imagick::COMPOSITE_COPYOPACITY 00imagick::CHANNEL_ALL); 
__________________
Recycle your old CD's, don't just trash them


Spidermonkey Tutorial;

If I helped out out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud

Reply With Quote
  #6  
Old June 18th, 2011, 11:11 PM
Myztacia Myztacia is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Location: Minnesota, USA
Posts: 96 Myztacia User rank is Lance Corporal (50 - 100 Reputation Level)Myztacia User rank is Lance Corporal (50 - 100 Reputation Level)Myztacia User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Day 3 h 20 m 42 sec
Reputation Power: 9
Yup, that would be the equivalent of imagecopymerge. I've used GD quite a bit, but my client uses MagickWand and wants to continue using it

Unfortunately, that will not quite work since it is MagickWand x.x I found the same function in MagickWand, however, it does not allow transparency.

Back to the drawing board for me I guess, haha. Thanks for trying

Reply With Quote
  #7  
Old January 13th, 2012, 12:17 AM
Myztacia Myztacia is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Location: Minnesota, USA
Posts: 96 Myztacia User rank is Lance Corporal (50 - 100 Reputation Level)Myztacia User rank is Lance Corporal (50 - 100 Reputation Level)Myztacia User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Day 3 h 20 m 42 sec
Reputation Power: 9
Unhappy Still frustrated with this :S

I have to revisit this code again and get the opacity per layer working.

I'm hoping a fresh pair of eyes could offer some insight? At this point, I'm even willing to PayPal some $ for a solution to my problem.

Again, the client does not want to change from ImageMagick. (*sigh*)

Thanks in advance!!

Reply With Quote
  #8  
Old October 1st, 2012, 08:09 AM
evenstar7139's Avatar
evenstar7139 evenstar7139 is offline
GIRL POWER!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 235 evenstar7139 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 31 m 46 sec
Reputation Power: 0
I stumbled across this post while researching on Google the same thing you are looking for: How to produce a functioning image generator that layers images with the correct transparencies.

I just wanted to say I feel your pain! I'm trying to keep up with other dog games on the web and add a script that dynamically generates the picture of a dog based on what colors/markings it was born with. It's been a frustrating process. I can layer the images just fine but the anti-aliasing and transparency have been giving me a fight.

You mentioned GD, I'm going to look into that. I've shelved this image generator idea for two years because of hitting a wall, but you mentioned GD, so I'm going to look into what that is. Maybe it will help me.

I never go on this site anymore but if you want to bounce ideas off each other send me an email. I'll message you my email address right after this post.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP5 - MagickWand Opacity issue

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap