andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


Slow when doing masking ...

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Image Mask
View previous topic :: View next topic  
Author Message
hunnebal
Newbie


Joined: 06 Mar 2004
Posts: 6

PostPosted: Sun Mar 07, 2004 11:49 pm    Post subject: Slow when doing masking ... Reply with quote

Hi, first of all thanks for this nice little utilities.

I've test it from your sites and its look cool. I was thinking to put a frame around my web family pictures using your technique.

One question though, I test it using your small images, masks, but it takes about at least 40 secs to display it, eventhough all its program, images, and masks is in my machine.

Thanks again.
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Mon Mar 08, 2004 6:51 am    Post subject: Reply with quote

Hi,

Unfortunatly, the process of the image mask needs to look at the mask image and the original image one pixel at a time. This is because it needs to determine the 'blackness' level of the mask pixel and then how opaque to display the original image pixel at that point. If you have a very complex mask, this process could take a lot longer (or so I've noticed happening with the masks on the demo area).

If you'd care to send me an example mask and example image that you're trying to mask, I can see how long it takes me to render. Might give you something to compare against.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
hunnebal
Newbie


Joined: 06 Mar 2004
Posts: 6

PostPosted: Mon Mar 08, 2004 6:29 pm    Post subject: Reply with quote

Hi Andy, thanks for your reply.

I'm wondering if there are such as way that we do not have to process each pixel at a time. If I have a square image and wants to put e.g a frame around it, how can I apply just the frame layer on top of the image background? Thanks
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Tue Mar 09, 2004 4:08 am    Post subject: Reply with quote

Okay, I'm assuming that the 'frame image' is something created in an art program to actual resemble a frame that you might hang on a wall, of something like that, right?

If that's the case, then it might be possible to do this fairly pain free - but not with the image mask class.

You will first create your frame picture and have what you want to show through be transparent (so the square the image will be in will be transparent in your frame picture). Save that as a PNG (at least 16-bits so you get the full transparency usage).

In a pseudo code kinda way, this is what you'll want to do:

Code:
load original image into origimg object
load frame image into frameimg object
if (origimg dimensions > frameimg dimensions)
    create resultimg with origimg dimensions
else
    create resultimg with frameimg dimenions
set imagealphablending on for resultimg
imagecopyresample origimg to resultimg
imagecopy frame to resultimg


and that is the simplest way to go about it that I think will work. Obviously there is a lot more you could do, such as resizing of the image to the frame or vis versa, or offering different positions to copy the frame image to.

andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Tue Mar 09, 2004 4:16 am    Post subject: Reply with quote

OH! As I was hitting the 'submit button on that last post I had an idea that would be REALLY easy to implement, but it depends on your frame picture.

Answer me this:

Is it a really simply frame image that just sits flush with the edges of the picture, or is it something fancy that has bits of the frame overlap the image?

If it's the former then simply use the 'dropshadow' class of mine. What that does is take a drop shadow, which is cut up into eight individual images and places them around the picture it creates. The eight images are: top left corner, top edge, top right corner, left edge, right edge, bottom left corner, bottom edge, and bottom right corner. If you split your frame picture up in the same was and name them the same as the 'drop shadow' images then you could do your frame like this:

PHP:
<?php

    
require_once "class.dropshadow.php";

    
$ds = new dropShadow(false);
    
$ds->setShadowPath('./shadows/');
    
$ds->loadImage('./images/test.jpg');
    
$ds->applyShadow('ffffff');
    
$ds->saveShadow('./images/output.jpg'null90);

?>


Pretty easy, eh?

andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
hunnebal
Newbie


Joined: 06 Mar 2004
Posts: 6

PostPosted: Tue Mar 09, 2004 10:23 pm    Post subject: Reply with quote

Hi Andy, thanks again.

The answer of your question is the former, that is the frame image sits flush with the edge of the picture.

How do you use the dropshadow class of yours. In the example, I see the picture(jpg) but don't see the frame image surrounding the picture?

What happen if the picture is bigger/smaller than the frame, how do you adjust the frame image to fit the picture nicely.

Thanks.

PS: Can I use any frame image(jpg,bmp,tiff,png,..) or do I have to use
a specific format to achive the result you mentioned above.
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Wed Mar 10, 2004 8:41 am    Post subject: Reply with quote

hunnebal wrote:
Can I use any frame image(jpg,bmp,tiff,png,..) or do I have to use a specific format to achive the result you mentioned above.


When using GD you can only use the file formats that that are available. That usually comes down to: jpg, png, gif, wbmp, and xbm.

I typically use png files if I need any kind of transparency and output in jpg format for viewing on a webpage.

As to the rest of your message - I pm'd you about it.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Image Mask All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group