problem in create thumb from image and save in database

See all posts Reply

problem in create thumb from image and save in database new!
by Ethar, 10 years, 5 months ago
hi
i try to take thumb image from original image
i want to take thum and keep the original image
the code used
$foo = new Upload($_FILES['mhna_pic']);
$fooThumb=$foo;
$fooThumb->file_new_name_body="image_resized";
$fooThumb->image_resize=true;
$fooThumb->image_convert=gif;
$fooThumb->image_x=90;
$fooThumb->image_y=105;
$foo2 = new Upload($_FILES['mhna_pic2']);
if ($foo or $foo2 or $fooThumb->uploaded) {
  $foo->Process('ups/');
  $fooThumb->Process('ups/');
  $foo2->Process('ups/');
  if ($foo or $foo2 or $fooThumb->processed) {
    $namei=$foo->file_dst_name;
    $nameiThumb=$fooThumb->file_dst_name;
as you see i use $nameiThumb to take copy from $foo this code work successfully in crop image but when store in name in database not work but save $foo name instead $nameiThumb
plz help me how to save $nameiThumb
$namei=$foo->file_dst_name;
$nameiThumb=$fooThumb->file_dst_name;
Reply
Re: problem in create thumb from image and save in database new!
by colin, 10 years, 5 months ago
Do not copy your object $foo. You have two sources images, so you can instantiate the class twice. For the first instance, you process two images. For the second instance, you process one image.

You should have something like this:
$foo = new Upload($_FILES['mhna_pic']);
$foo2 = new Upload($_FILES['mhna_pic2']);

if ($foo->uploaded && $foo2->uploaded) {

  // save main image
  $foo->Process('ups/');
  $first = $foo->file_dst_name;

  // make thumbnail
  $foo->file_new_name_body="image_resized";
  $foo->image_resize=true;
  $foo->image_convert=gif;
  $foo->image_x=90;
  $foo->image_y=105;
  $foo->Process('ups/');
  $thumb = $foo->file_dst_name;

  // save second image
  $foo2->Process('ups/');
  $second = $foo2->file_dst_name;

  if ($foo->processed && $foo2->processed) {
    // save your image names here: $first, $thumb, $second
  }
}
Reply
Re: problem in create thumb from image and save in database new!
by Ethar, 10 years, 5 months ago
hi
thx for yu rreplay, but in this way save the same name (image_resized) for $foo and $thumb
i want to
$foo (stay the same name take by the class).
$thumb (new resized name)Reply
Re: problem in create thumb from image and save in database new!
by Ethar, 10 years, 5 months ago
no no its work successfully thxReply
Re: problem in create thumb from image and save in database new!
by colin, 10 years, 5 months ago
The names are different, as file_new_name_body is used only fo rthe thumbnail. Use file_new_name_body in other places if you need to.Reply
Re: problem in create thumb from image and save in database new!
by Ethar, 10 years, 5 months ago
thxxxxxxxxxxxxxxxxxxxxxx for you its work successfullyReply