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.


Support for Gifs?

 
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 -> Drop Shadowed Thumbnail Creator
View previous topic :: View next topic  
Author Message
Monkeyboy
Newbie


Joined: 27 Jul 2003
Posts: 3

PostPosted: Sun Jul 27, 2003 8:49 pm    Post subject: Support for Gifs? Reply with quote

Is there any way to get the dropshadow to also work for other types of files other than jpgs? I'm trying to put together a small gallery that would use multiple types of file including gifs, jpegs, pngs and I would like to be able to give them all drop shadows. Thanks for your help. And thanks for the script it really is great. Very Happy
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 Jul 28, 2003 4:06 am    Post subject: Reply with quote

Hi MonkeyBoy,

Welcome to the board!

Unfortunatly, there's no real easy way to have gif support right now. You see, the script creates true colour images - which cannot be done with Gifs, and the GD library right now does not support the writing of GIF images because of the whole LZW compression patent. You might be able to find a patch for GD - but then you'd have to recompile GD and make some code updates to the class too.

What you could do, if you have it available, is use something like Image Magick to convert the image for you (but if you have IM then you might want to investigate using that to also produce the drop-shadow.) You may also be able to find other shell converts for GIFs.

Do you need to display the image as a GIF? You could read in the GIF file (I think the latest GD bundled with PHP has GIF read support) and then just convert it to a JPG/PNG and display it like that.

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


Joined: 27 Jul 2003
Posts: 3

PostPosted: Sat Aug 02, 2003 3:36 pm    Post subject: Reply with quote

Thanks for the help. I've switched to using Imagemagick to create the thumbnails. But couldn't find any help for creating the drop shadows with ImageMagick, so I'll have it format the thumbnails as jpg and then apply the drop shadow with this class. 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: Sat Aug 02, 2003 3:50 pm    Post subject: Reply with quote

Taken from the book 'PHP Graphics Handbook' (Wrox):

PHP:
<?php

function MakeShadowFile($imagefile,  // which file to shade
                        
$threshold,  // threshold amount
                        
$shadowsize// size of shadow
                        
$shadowoffsetx,  // shadow offset in X direction
                        
$shadowoffsety,  // and in Y direction
                        
$shadowmax="50%"// amount of shadowing
                        
$outputfile="auto",  // name of output file
                        
$imagesizex="auto",  // imagesize
                        
$imagesizey="auto")
{
    if (
$imagesizex==="auto" || $imagesizey==="auto") {
        
$tmp=getimagesize($imagefile);
        
$imagesizex=$tmp[0];
        
$imagesizey=$tmp[1];
    }
    if (
$outputfile==="auto") {
        
$outputfile=$imagefile;
    }

    
$fn_empty=tempnam("/tmp""shadow");
    
$fn_mask=tempnam("/tmp""shadow");
    
$fn_invmask=tempnam("/tmp""shadow");
    
$fn_toshadow=tempnam("/tmp""shadow");
    
$fn_shadow=tempnam("/tmp""shadow");
    
$fn_maskshadow=tempnam("/tmp""shadow");

    
$tmpim=imagecreate($imagesizex+$shadowoffsetx+$shadowsize$imagesizey+$shadowoffsety+$shadowsize);
    
imagecolorallocate($tmpim255,255,255);
    
imagepng($tmpim$fn_empty);
    
imagedestroy($tmpim);

    
exec("convert $imagefile -threshold $threshold png:$fn_mask");
    
exec("convert png:$fn_mask -negate png:$fn_invmask");
    
exec("composite -geometry +$shadowoffsetx+$shadowoffsety png:$fn_mask png:$fn_empty png:$fn_toshadow");
    
exec("convert -depth 24 -gaussian ${shadowsize}x".((int)($shadowsize/3))." png:$fn_toshadow png:$fn_shadow");
    
exec("composite -depth 24 png:$fn_invmask -compose plus png:$fn_shadow png:$fn_maskshadow");
    
exec("composite -depth 24 png:$fn_maskshadow -dissolve $shadowmax png:$fn_empty png:$fn_maskshadow");
    
exec("composite png:$fn_maskshadow -compose multiply $imagefile $outputfile");

    
unlink($fn_empty);
    
unlink($fn_mask);
    
unlink($fn_invmask);
    
unlink($fn_toshadow);
    
unlink($fn_shadow);
    
unlink($fn_maskshadow);
}

//MakeShadowFile("piecex1.png", "99%", 15, 10, 10, "60%", "piecex1shadow.png");


?>


Hope this helps you out.

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


Joined: 27 Jul 2003
Posts: 3

PostPosted: Sun Aug 03, 2003 11:20 pm    Post subject: Reply with quote

Thank you very much once again. Although I won't be able to try it until I get back from vacation on the 20th.

Thanks for all your help! Very Happy
Back to top
View user's profile Send private message
TITI
Newbie


Joined: 09 Aug 2003
Posts: 1

PostPosted: Sat Aug 09, 2003 4:37 am    Post subject: Reply with quote

I think there's a way for GIF ( but I don't know ) , you can see it in http://www.zideanart.com ... Shocked
Back to top
View user's profile Send private message
V@no
Light Poster


Joined: 10 Apr 2003
Posts: 30

PostPosted: Mon Aug 11, 2003 12:50 pm    Post subject: Reply with quote

dead link
Back to top
View user's profile Send private message Visit poster's website
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 -> Drop Shadowed Thumbnail Creator 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