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.


Wrong Colours when cropping

 
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 -> Crop Canvas
View previous topic :: View next topic  
Author Message
tribal75
Newbie


Joined: 27 Jul 2004
Posts: 2

PostPosted: Tue Jul 27, 2004 11:36 am    Post subject: Wrong Colours when cropping Reply with quote

Hi to everyone,
I downloaded this amazing class and I used under different platforms for my works. But now I'm getting mad over this absurd problem. I made an upload utility that takes an image file, put in a dir and then create a Thumbnail. If the "usertype" of the image is "stabile" after resizing it's cropped with crop canvas.

Here's the code:
PHP:
<?php function buildThumbs($filename$img_type$extension){

if (
$img_type=="stabile"){
$fileOrigine=DIR_IMGS_STABILI.$filename;
$fileDestinazione=DIR_IMGS_STABILI."_thumbs/Thumb_".$filename;
} else {
if (
$extension=="mobi_") return;
$filename $extension.$filename;
$fileOrigine=DIR_IMGS_APPARTAMENTI.$filename;
$fileDestinazione=DIR_IMGS_APPARTAMENTI."_thumbs/Thumb_".$filename;
}
list(
$l$a) = GetImageSize($fileOrigine);
if (
$l+$a==|| $l+$a >5000) {
return 
"Thumb_none.jpg";
}

if (
$img_type=="appartamento"){
$larghezza min($lLARG_THUMB);
$altezza floor($larghezza $a $l);
if (
$altezza ALTE_THUMB) {
$larghezza floor($larghezza ALTE_THUMB $altezza);
$altezza ALTE_THUMB;}
}
else {
if (
$l==min($l$a)){
$larghezza WIDTH_STABILE;
$altezza floor($larghezza $a $l);
} else { 
$altezza WIDTH_STABILE;
         
$larghezza floor($altezza $l $a);
         }
}


$vi ImageCreate($larghezza$altezza);
$tipo substr($filename, -3);

if (
strtolower($tipo) == "jpg"$tipo="jpeg";
eval (
"\$im = ImageCreateFrom$tipo('$fileOrigine');");
ImageCopyResized($vi$im0000$larghezza$altezza$l$a);
if (
$tipo="jpeg"$eval_expression"Image$tipo(\$vi, '$fileDestinazione', 100);";
else 
$eval_expression="Image$tipo(\$vi, '$fileDestinazione');";
eval (
$eval_expression);
ImageDestroy($vi);

if (
$tipo=="stabile"){
echo 
"file destinazione: ".($fileDestinazione);
$cc = new canvasCrop();

$cc->loadImage($fileDestinazione);
$cc->cropToDimensions(00WIDTH_STABILEHEIGHT_STABILE);
$cc->saveImage($fileDestinazione);

$cc->flushImages();
}
return 
"Thumb_".$filename;
}
//function buildThumbs ?>


But on my PC with Easy PHP 1.6.0.0 this works great... on my providers Server colours appear really poor.
Here the example:


I tried to set the quality etc etc... but still can't get over it!!

I also tried to save in PNG format but the colours are still the same!! Shocked

Please help me if you can!
Back to top
View user's profile Send private message MSN Messenger
amnuts
Site Admin


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

PostPosted: Tue Jul 27, 2004 5:13 pm    Post subject: Reply with quote

Hi there, and welcome to the board!

What version of GD runs on the server? If it's anything less than 2.0.1 then there's a good chance that you may get some funky colourings (I know I did when trying on an older version of GD).

Looking at your code I notice you use 'ImageCopyResized'. This might suggest you do in fact use GD 1.x. If you know you use GD 2.x then change that to 'ImageCopyResampled'... Better yet, go and grab the class.dropshadow.php class from this site. It gives you a huge amount of resizing options - don't let the name of the class fool you - it's more a thumbnail creator than a dropshadow creator (it's a thumbnailer with the ability to wrap your image up with a drop shadow effect, but you have no need to HAVE to do that if you just want to resize!)

Try out the resampled first. If that doesn't work because you're using an older version of GD then might I suggest looking at this thread:

http://php.amnuts.com/forums/viewtopic.php?t=36

for decent resampling functions that will work with GD 1.x.

And if you want, check out that additional class - you may find a use for it! Smile

Regards,

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


Joined: 27 Jul 2004
Posts: 2

PostPosted: Wed Jul 28, 2004 3:01 am    Post subject: Reply with quote

I got GD 2.01 ... as you suggested I used ImageCopyResampled and ImageCreateTrueColor and it worked great!

I soon watch after your dropshadow class. Smile

Thanks for your kindness and support.
I hope to support you soon! Smile

I know it's a little bit OT... is there any Commercial License or Agreement to use your classes?
Back to top
View user's profile Send private message MSN Messenger
amnuts
Site Admin


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

PostPosted: Wed Jul 28, 2004 3:58 am    Post subject: Reply with quote

tribal75 wrote:
I got GD 2.01 ... as you suggested I used ImageCopyResampled and ImageCreateTrueColor and it worked great!


Just the kind of thing I like to hear! Smile

tribal75 wrote:
Is there any Commercial License or Agreement to use your classes?


Good question. Everything on this site should be considered free for personal or non-profit use. I haven't specifically written anything down for commerical use, so I don't think it's fair to say that anyone HAS to pay, though it is more encoraged/expected that you donate something for commerical use. I plan to revamp the site soon to make this much clearer, and to spell out commerical use prices. However, I'm thinking something along the lines of up to a $25 donation for commerical use, depending on the script. It's my hope, though, to always keep the scripts on php.amnuts.com free for personal and non-commerical use. Smile (However, I may put full-blown applications on amnuts.com as commerical release only, and not free.)

As for licensing... Some are specifically GPL, and so you would follow the guidlines for that license scheme. All code is copyright me, unless otherwise stated. Don't claim the classes as your own and give credit where it's due... Ermm.... That's all I can think of right now. Smile

Hope that helps answer your questions. If not, just let me know!

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 -> Crop Canvas 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