• [Mod] Auto image resize on upload v2.0.1 (2010-12-18) 4 0 5 1
Currently:  

Author Topic: [Mod] Auto image resize on upload v2.0.1 (2010-12-18)  (Read 506975 times)

0 Members and 1 Guest are viewing this topic.

Offline gooberlx

  • Pre-Newbie
  • Posts: 6
    • View Profile
[Mod] Auto image resize on upload.
« Reply #30 on: April 11, 2003, 09:37:17 AM »
I have found a hack around it by commenting out the errors added and forcing '1' for $ok where the code checks for image size, width and height.

It must not have been resizing the image before those checks.

Alas, I'm not very good with perl or php, so I'm kinda stumbling through this via trial and error.  :oops:

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] Auto image resize on upload.
« Reply #31 on: April 11, 2003, 10:50:29 AM »
but, if u do that, u wont have restrict on max thumbnail file size...

u know, now I look at those changes and think: " this is not the way it should be done..." :?
try change step 2.2. to this:
delete the changes u made in that step:
Code: [Select]
   if ($this->auto_image[$this->image_type] == 1) {
         $ok = 1;
      }

then, after
Code: [Select]
 function check_image_size() {
add this:
Code: [Select]
   if ($this->auto_image[$this->image_type] == 1) {
         return 1;
      }
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline gooberlx

  • Pre-Newbie
  • Posts: 6
    • View Profile
[Mod] Auto image resize on upload.
« Reply #32 on: April 11, 2003, 12:18:07 PM »
making some headway:

i get only this now:
Code: [Select]

Error uploading image file:
103_0335.jpg: Image size invalid


with the max res at 600x600 and quality at 85 (ImageMagick), I find it hard to believe that this file is over 300K.  :?

Anyway, I'm gonna hit the sack.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] Auto image resize on upload.
« Reply #33 on: April 11, 2003, 01:41:50 PM »
ah, ok, I see now.
this how that function should start:
Code: [Select]
 function check_image_size() {
    $this->image_size = @getimagesize($this->upload_file);
    if ($this->auto_image[$this->image_type] == 1) {
         return 1;
      }
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline gooberlx

  • Pre-Newbie
  • Posts: 6
    • View Profile
[Mod] Auto image resize on upload.
« Reply #34 on: April 11, 2003, 10:49:42 PM »
hmmmm, still the same problem. Here's how that whole section looks, and then where it's called: Somewhere $ok must be getting set to 0. But if that were true then certainly one of the other error messages should have be printed out.

Code: [Select]

function check_image_size() {
$this->image_size = @getimagesize($this->upload_file);
if ($this->auto_image[$this->image_type] == 1) {
return 1;
}
$ok = 1;

if ($this->image_size[0] > $this->max_width[$this->image_type]) {
$ok = 0;
$this->set_error($this->lang['invalid_image_width']);
}

if ($this->image_size[1] > $this->max_height[$this->image_type]) {
$ok = 0;
$this->set_error($this->lang['invalid_image_height']);
}

return $ok;
}

Code: [Select]

if ($user_info['user_level'] != ADMIN) {
if (!$this->check_max_filesize()) {
$this->set_error($this->lang['invalid_file_size']);
$ok = 0;
}
if (eregi("image", $this->HTTP_POST_FILES[$this->field_name]['type'])) {
if (!$this->check_image_size()) {
$ok = 0;
}
}
}


So it seems the problem must be coming from check_max_filesize(), which would make sense since we're not resizing it until after that.

What I've done is copy that new "if" section and put it right after check_max_filesize().

Code: [Select]

  function check_max_filesize() {

if ($this->auto_image[$this->image_type] == 1) {
return 1;
}

    if ($this->HTTP_POST_FILES[$this->field_name]['size'] > $this->max_size[$this->image_type]) {
      return false;
    }
    else {
      return true;
    }
  }


But I still had to leave the new "if" statement in check_image_size(), otherwise I'd get invalid width and height again. So currently it works, and both check_image_size() and check_max_filesize() have that new "if" statement, but it still feels like a hack for some reason; like fixing a house with ducted-tape.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] Auto image resize on upload.
« Reply #35 on: April 11, 2003, 11:47:00 PM »
no, u did right, that how it should be...just wondering how come it works for me... :?
anyway, also, I think in your last cade should be return true; instead of return 1;
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline stb

  • Pre-Newbie
  • Posts: 3
    • View Profile
[Mod] Auto image resize on upload.
« Reply #36 on: April 19, 2003, 02:42:09 PM »
privet, Vano

good hack, but as a idea (i did it on my gallery) to keep an original image too. a few concepts:
1) if needed resize -- resize
2) default display resized image, but make smthn. like button "hi res" to view an original
3) u'll need new /data/ dirs and some corrections to tables in the base

it'll be good to include such things in new versions of 4images, so as MPC

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] Auto image resize on upload.
« Reply #37 on: April 19, 2003, 03:46:49 PM »
Quote from: stb
2) default display resized image, but make smthn. like button "hi res" to view an original

On my site I use [Mod] Show original image in new window by clicking on image.
And this mod automaticaly copy original file to /big/ folder if the image is being resized (/big/ folder also automaticaly created if its not exist).
Just need use in Step 1. this code:
Code: [Select]
//--------------------------------------------
//--------- Auto Image Resizing --------------
//--------------------------------------------
                  if ($config['auto_image'] && !$uploaderror) {
                     $src_copy = MEDIA_PATH."/".$cat_id."/big";
                     if ($direct_upload) {
                        $src = MEDIA_PATH."/".$cat_id."/".$new_name;
                        $src_copy = MEDIA_PATH."/".$cat_id."/big";
                    }
                    else {
                        $src = MEDIA_TEMP_PATH."/".$new_name;
                    }
                    $do_resize = 0;
               if ($image_info = @getimagesize($src)) {
                       if ($image_info[2] == 1 || $image_info[2] == 2 || $image_info[2] == 3) {
                          $do_resize = 1;
                     }
                   }
                   if ($do_resize) {
                     if (!function_exists(init_convert_options)) {
                           require(ROOT_PATH.'includes/image_utils.php');
                        }
                        $convert_options = init_convert_options();
         if (!$convert_options['convert_error']) {
if ($image_info[0] > $config['max_image_width'] || $image_info[1] > $config['max_image_height']) {
$result = true;
 if (!@is_dir($src_copy)) {
   $oldumask = umask(0);
   $result = mkdir($src_copy);
   umask($oldumask);
   if (!@is_dir($src_copy) || !$result) {
     $result = mkdir($src_copy, 0755);

   }
 }
if ($result == true){
copy($src, $src_copy."/".$new_name);
}
                     $convert_options = init_convert_options();
                     if (!$convert_options['convert_error']) {
                       $quality = (intval($config['auto_image_quality']) && intval($config['auto_image_quality']) <= 100) ? intval($config['auto_image_quality']) : 100;
                      if (!resize_image($src, $quality, $config['max_image_width'], 1)) {
                        $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].": ".$new_name;
                           $uploaderror = 1;
                        }
                    }
                  }else{
                  $do_resize = 0;
                  }
                       }
                     }
                  }
//-------------------------------------------

P.S. it works on my windows system, dont know about any others :roll:
« Last Edit: September 28, 2008, 01:51:25 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Niko

  • Pre-Newbie
  • Posts: 2
    • View Profile
[Mod] Auto image resize on upload.
« Reply #38 on: April 24, 2003, 10:48:46 PM »
V@no:

First: thanks for your nice addon! I like it very much!

I'm planning to use it together with this function. Perhaps it will work someday...  :D

But i have a question concerning your last posting here in this thread:
The files in the big-path can't be deleted via ftp. They have the "owner"-right of the user "wwwroot". So my ftp (which has the userid "XYZ") gets an "Permission denied" error.

Can you give me a hint how to set the "owner-right" properly?
« Last Edit: January 04, 2008, 09:00:28 PM by Nicky »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] Auto image resize on upload.
« Reply #39 on: April 25, 2003, 12:01:26 AM »
I'm not sure, since I never had deal with *NIX systems and CHMOD things...:?
but it seems for me, that this line set CHMOD to 755:
Code: [Select]
                                                       if (!@is_dir($src_copy) || !$result) {
                                                          $result = mkdir($src_copy, 0755);

                                                        }

I might be wrong though...
anyone else has a hint? ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline HelpMeNow

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
[Mod] Auto image resize on upload.
« Reply #40 on: April 25, 2003, 12:56:13 AM »
V@no,

I just wanted to thank you for this great mod. I LOVE IT!  :D

Thanks for your great work.

Offline andersen

  • Newbie
  • *
  • Posts: 34
    • View Profile
[Mod] Auto image resize on upload.
« Reply #41 on: May 10, 2003, 01:41:05 PM »
This is very great mod. I had modify 5 minutes ago, my site didn't show any error.

but I had found one error is...

The original default setting for Auto-resize is "no" and
Auto-resize qualitu is empty.

when I had set to "yes" and with 100 for quality. press save changes.

but when after save changes back to setting again. the Auto-resize setting are back to default. system never saves my setting.

May I know which step I had miss?

Thanks
What's wrong, huh?

Offline andersen

  • Newbie
  • *
  • Posts: 34
    • View Profile
[Mod] Auto image resize on upload.
« Reply #42 on: May 10, 2003, 01:51:03 PM »
please ignore my previous question...

My careless forget to run "install_autoimage.php"

now it save.

Thanks
What's wrong, huh?

Offline andersen

  • Newbie
  • *
  • Posts: 34
    • View Profile
[Mod] Auto image resize on upload.
« Reply #43 on: May 10, 2003, 02:08:03 PM »
Dear all,

once again, new error for myself.

Everything work perfect, if user post over limit of pixels the server reject but will not auto-resize the over limit picture. System list error as below

"Error uploading image file: test_2.jpg"

Do this process related with ImageMagick?

Thanks
What's wrong, huh?

Offline sookes

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • http://www.deliasdesign.com
will not resize images
« Reply #44 on: May 14, 2003, 05:52:31 PM »
I have spent 2 hours working on this.  I've redone it and checked to make sure I was using original files from the most recent version download.  The database is set up okay.

I've read through all the posts and have gained no illumination into what could go wrong.

The settings show up correctly in the control panel and can be manipulated there.

But no matter what I do, a user cannot upload a file over the specified max size.  It will not  resize the images.

I really like this and would like for it to work.

Any new ideas?