For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > March 2007 > image upload









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author image upload
hannes

2007-03-27, 8:02 am

I have a problem with uploading images and creating thumbs from it.

Not all the time, but sometimes, the full size image is completely
uploaded and correct, while the thumbnail only builds a vertical part
of the real image... the rest is grey..

How is that possible? Uploading is not the problem, but resizing
somehow is i guess.

Please help me,

Hannes

Erwin Moller

2007-03-27, 8:02 am

hannes wrote:

> I have a problem with uploading images and creating thumbs from it.
>
> Not all the time, but sometimes, the full size image is completely
> uploaded and correct, while the thumbnail only builds a vertical part
> of the real image... the rest is grey..
>
> How is that possible? Uploading is not the problem, but resizing
> somehow is i guess.
>
> Please help me,
>
> Hannes


Hi Hannes,

Check line 134 in your sourcecode of the script that handles the
resizing....

How do you expect us to answer such a question based on the information we
receive?

Regards,
Erwin Moller

hannes

2007-03-27, 7:00 pm

On 27 mrt, 11:50, Erwin Moller
< since_humans_read_this_I_am_spammed_too_
m...@spamyourself.com> wrote:
> hannes wrote:
>
>
>
>
>
> Hi Hannes,
>
> Check line 134 in your sourcecode of the script that handles the
> resizing....
>
> How do you expect us to answer such a question based on the information we
> receive?
>
> Regards,
> Erwin Moller


Haha.. sorry..
well, i thought maybe someone recognises this problem. Why can this
image be grey at the bottom? Maybe you've seen this before and you can
tell me what i should be thinking about?




Evil Otto

2007-03-27, 7:00 pm

On Mar 27, 11:32 am, "hannes" <hann...@gmail.com> wrote:
> On 27 mrt, 11:50, Erwin Moller
>
>
>
> < since_humans_read_this_I_am_spammed_too_
m...@spamyourself.com> wrote:
>
>
>
>
>
>
>
>
>
> Haha.. sorry..
> well, i thought maybe someone recognises this problem. Why can this
> image be grey at the bottom? Maybe you've seen this before and you can
> tell me what i should be thinking about?


IMHO you should be thinking about providing more information :)

The code would be a good place to start, as well as your PHP version,
what web server you have, what file formats you're allowing, how much
memory you have in your server AND have allocated to PHP..

Basically ANY information would be helpful.

hannes

2007-03-29, 7:00 pm

On 27 mrt, 21:27, "Evil Otto" <zburn...@gmail.com> wrote:
> On Mar 27, 11:32 am, "hannes" <hann...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> IMHO you should be thinking about providing more information :)
>
> The code would be a good place to start, as well as your PHP version,
> what web server you have, what file formats you're allowing, how much
> memory you have in your server AND have allocated to PHP..
>
> Basically ANY information would be helpful.- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -


this is my code where something goes wrong:
$handle = fopen($tmpHolder, "rb"); // opent 'temp/tmp.img'
echo $handle;
$contents = fread($handle, filesize($tmpHolder));

if($original = imagecreatefromstring($contents)){
}
else{
// nog een keer
if($original = imagecreatefromstring($contents)){
}
else{
exit("mislukt, probeer het opnieuw<BR>");
}
}
$source = imagecreatefromstring($contents);
$original_width = imagesx($original);
$original_height = imagesy($original);

if($original_width < $formaatSmall){
$newwidth = $original_width;
$newheight = $original_height;
}else{


$percent = ($original_height/$original_width);
if($original_width>$original_height){
//horizontaal
//percent < 1
$newwidth = $formaatSmall;
$newheight = $formaatSmall*$percent;
}
else if($original_width<$original_height){
//verticaal
//percent > 1
$newwidth = $formaatSmall/$percent;
$newheight = $formaatSmall;
}
else if($original_width=$original_height){
//vierkant
//percent = 1
$newwidth = $formaatSmall;
$newheight = $formaatSmall;

}
}
$thumb = imagecreatetruecolor($newwidth, $newheight);

if (!imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth,
$newheight, $original_width, $original_height)){
exit("aanmaken van thumbnail mislukt<BR>");
}

$thumbnail = $folder_small."/".$form_bestandsnaam;

if(!is_file($thumbnail)){
$handle2 = fopen($thumbnail,'x');
chmod($thumbnail, 0777);
fclose($handle2);
}
imagejpeg ($thumb, $thumbnail, 60);

fclose($handle);

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com