Enrique
|
Posted: 01/17/2004, 7:25 AM |
|
Here a code to process an uploaded file and make thumb.
Put this in "After Process File"
I
---> Custom Code
The complete function is :
function productos_FileUpload1_AfterProcessFile()
{
global $productos;
$productos_FileUpload1_AfterProcessFile = true;
//End productos_FileUpload1_AfterProcessFile
// -------------------------
crearthumb ($productos->FileUpload1->FileFolder.$productos->FileUpload1->Value,"../thumbs/".$productos->FileUpload1->Value,80,80);
//Custom Code @13-865E2CCD
// Write your own code here.
// -------------------------
//End Custom Code
//Close productos_FileUpload1_AfterProcessFile @12-8B464092
return $productos_FileUpload1_AfterProcessFile;
}
my "crearthumb" function is--->
function crearthumb($nombre,$thnombre,$ancho,$alto)
{
global $gd2;
if (preg_match("/jpg|jpeg/",$nombre))
{
$src_img=imagecreatefromjpeg($nombre);
}
if (preg_match("/png/",$nombre))
{ $src_img=imagecreatefrompng($nombre); }
$antiguo_x=imageSX($src_img);
$antiguo_y=imageSY($src_img);
if ($antiguo_x > $antiguo_y)
{
$thumb_w=$ancho;
$thumb_h=$antiguo_y*($alto/$antiguo_x);
}
if ($antiguo_x < $antiguo_y) {
$thumb_w=$antiguo_x*($ancho/$antiguo_y);
$thumb_h=$alto;
}
if ($antiguo_x == $antiguo_y) {
$thumb_w=$ancho;
$thumb_h=$alto;
}
if ($gd2==""){
$dst_img=ImageCreate($thumb_w,$thumb_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$antiguo_x,$antiguo_y);
}else{
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$antiguo_x,$antiguo_y);
}
if (preg_match("/png/",$system[1])){
imagepng($dst_img,$thnombre);
}
else {
imagejpeg($dst_img,$thnombre);
}
imagedestroy($dst_img);
imagedestroy($src_img);
}
At top of this page....
|
|
|
kescott
Posts: 49
|
Posted: 02/03/2004, 9:03 AM |
|
I'm getting a parse error when I publish with your code.
The message reads,"Parse error: parse error, unexpected ')' in /var/www/html/personnel/newentry_events.php on line 16
"
it is refering to
crearthumb ($productos->FileUpload1->FileFolder.$productos->FileUpload1->Value,"../thumbs/".$productos->FileUpload1->Value,80,80);
Can you help?
_________________
B.S. of Computer Science
Class of 2005
Norfolk State University
Norfolk, VA
http://www.nsu.edu
|
|
|
feha
Posts: 712
|
Posted: 02/06/2004, 8:02 AM |
|
I think there is NO SYNTAX ERROR in Enriques function ...
Check Your code please...
He forgot to mention that this images operations REQUIRE GD library
enabled in your php.ini file ...
or extenstions ...
regards
feha
www.vision.to
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
capone
|
Posted: 02/16/2004, 7:47 AM |
|
I have also use this code and it's giving me the same problem kescott
is facing.
Since "FEHA" seems to know more about how to make it work why don't you please help us on the GD library in our PHP.ini file....
Because beside the parse error it keeps pointing to an invalid function
crearthumb ($productos->FileUpload1->FileFolder.$productos->FileUpload1->Value,"../thumbs/".$productos->FileUpload1->Value,80,80);
Thank you in advance...
|
|
|
Kevin
|
Posted: 02/20/2004, 5:39 AM |
|
Does anyone have a suitable answer to my question?
|
|
|
LuteD
|
Posted: 06/12/2004, 10:37 AM |
|
I tried this and it works great.
You have to have GD2 enabled. In your php.ini, un-comment the line:
;extension=php_gd2.dll
Also make sure your extensions diectory is set. By default it should be:
extension_dir = "./"
I changed mine to: extension_dir = "./extensions"
|
|
|
feha
Posts: 712
|
Posted: 06/22/2004, 7:08 AM |
|
Great
_________________
Regards
feha
www.vision.to
feedpixel.com |
|
|
Damian
|
Posted: 06/23/2004, 11:41 PM |
|
I am having trouble getting GD2 to work on my local IIS. PHP works fine but
no GD functions.
I have copied the dll to the extensions directory and removed the ";"
I have played with many variations of the extension_dir but cannot get it to
work...
Anyone else have difficulties and managed to resolve them?
"LuteD" <LuteD@forum.codecharge> wrote in message
news:540cb3f52c97ce@news.codecharge.com...
> I tried this and it works great.
> You have to have GD2 enabled. In your php.ini, un-comment the line:
> ;extension=php_gd2.dll
> Also make sure your extensions diectory is set. By default it should be:
> extension_dir = "./"
> I changed mine to: extension_dir = "./extensions"
>
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
Visiomart
Posts: 13
|
Posted: 07/02/2004, 1:28 PM |
|
Hello Guys & Gals
I have used this code and changed the page names as usual and uncommented the extention but only php_gd.ll is written there and available in my php.ini
All it keeps bringing to me is that
" cannot call to a member function imagecreatefromjpeg ()"
I wanted to know wheter i have to declare the function imagecreatefromjpeg or not I'm totally confused
Please Please if anyone can give me his version of the code or help enable mine work i will be glad to be helped by this forum..
thanks in advance
capone
_________________
Don Capone |
|
|
Visiomart
Posts: 13
|
Posted: 07/04/2004, 3:00 AM |
|
Hi all
Thanks for your guidance i have been able to download the new PHP5 and the code worked great.. Thanks
_________________
Don Capone |
|
|
val
|
Posted: 07/07/2004, 4:30 AM |
|
|
|
|
headhunter
Posts: 130
|
Posted: 07/15/2004, 5:45 AM |
|
Hi all,
everything works fine.
I just wonder how to delete the thumb when you delete an image from the database?
That code would go in the "After delete file" I think.
Thanks
|
|
|
|