4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
February 22, 2018, 09:49:45 AM

Login with username, password and session length
Search:     Advanced search
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Modifications / Modifikationen
| |-+  Mods & Plugins (Releases & Support) (Moderators: mawenzi, Rembrandt)
| | |-+  [Mod] Auto image resize on upload v2.0.1 (2010-12-18)
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 3 4 5 ... 33 » »» Print
Current Topic Rating: ****
Author Topic: [Mod] Auto image resize on upload v2.0.1 (2010-12-18)  (Read 444136 times)
V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 565

mmm PHP...


View Profile WWW
« on: February 20, 2003, 03:23:29 AM »

This MOD will resize uploaded by users images and thumbnails to Max. Image Width set in settings.
Working on v1.7 - v1.7.9


-----------------------------------------------
Files to edit:
member.php
includes/upload.php
admin/settings.php
lang/<yourlanguage>/admin.php

-----------------------------------------------


Step 1
Open /member.php

Find:
1
   if (!$uploaderror) {

Insert above (if u installed "MOD Annotation by SLL" then, u'll need do Step 7 too):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//--------------------------------------------
//--------- Auto Image Resizing --------------
//--------------------------------------------
    if ($config['auto_image'] && !$uploaderror)
    {
      if ($direct_upload)
      {
        $src = MEDIA_PATH."/".$cat_id."/".$new_name;
      }
      else
      {
        $src = MEDIA_TEMP_PATH."/".$new_name;
      }
      $do_resize = 0;
      if ($image_info = @getimagesize($src))
      {
        if ($image_info[2] > 0 && $image_info[2] < 4 && $image_info[0] > $config['max_image_width'] || $image_info[1] > $config['max_image_height'])
        {
          if (!function_exists("init_convert_options"))
          {
            require(ROOT_PATH.'includes/image_utils.php');
          }
          $convert_options = init_convert_options();
          if (!$convert_options['convert_error'])
          {
            $quality = intval($config['auto_image_quality']);
            $quality = ($quality >= 0 && $quality <= 100) ? $quality : 85;
            if (!resize_image($src, $quality, $config['max_image_width'], 1, $config['max_image_height']))
            {
              $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].": ".$new_name;
              $uploaderror = 1;
            }
          }
        }
      }
    }
    if ($config['auto_thumbnail'] && !$uploaderror)
    {
      if ($direct_upload)
      {
        $src = THUMB_PATH."/".$cat_id."/".$new_name;
      }
      else
      {
        $src = THUMB_TEMP_PATH."/".$new_name;
      }
      $do_resize = 0;
      if ($image_info = @getimagesize($src))
      {
        if ($image_info[2] > 0 && $image_info[2] < 4 && $image_info[0] > $config['max_thumb_width'] || $image_info[1] > $config['max_thumb_height'])
        {
          if (!function_exists("init_convert_options"))
          {
            require(ROOT_PATH.'includes/image_utils.php');
          }
          $convert_options = init_convert_options();
          if (!$convert_options['convert_error'])
          {
            $quality = intval($config['auto_image_quality']);
            $quality = ($quality >= 0 && $quality <= 100) ? $quality : 85;
            if (!resize_image($src, $quality, $config['max_thumb_width'], 1, $config['max_thumb_height']))
            {
              $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].": ".$new_name;
              $uploaderror = 1;
            }
          }
        }
      }
    }
//--- End Auto Image Resizing ----------------




Step 2
Open /includes/upload.php

Find:
1
   $this->max_height['media'] = $config['max_image_height'];

Insert below:
1
2
   $this->auto_image['media'] = $config['auto_image'];
    $this->auto_image['thumb'] = $config['auto_thumbnail'];



Step 2.2
Find:
1
2
   $this->image_size = @getimagesize($this->upload_file);
    $ok = 1;

Insert below:

1
2
3
    if ($this->auto_image[$this->image_type]) {
      return 1; //auto image is on, don't need check for anything else.
    }




Step 3
Open /admin/settings.php

Find:
1
 show_setting_row("upload_emails");

Insert below:
1
2
 show_setting_row("auto_image", "radio");
  show_setting_row("auto_image_quality");




Step 4
Open /lang/<yourlanguage>/admin.php

Find:
1
$setting['auto_thumbnail_quality'] = "Thumbnail quality<br /><span class=\"smalltext\">0 to 100</span>";

Insert below:
1
2
$setting['auto_image'] = "Auto-resize image";
$setting['auto_image_quality'] = "Auto-resize image quality";




Step 5
Download attached file below.

Unzip it and upload to your 4images ROOT dir.
Execute it http://yoursiteaddress/4images/install_autoimage.php




Step 6
Go to Admin Control Panel -> settings. Under Upload settings u should find new options. Make sure "Max. image size in KB" is set to a high enough number




Step 7
This step u'll need only if u installed MOD Annotation by SLL
All u need to do is move code of Annotation, that u added in member.php, move it below the code u added in Step 1


Step 8 (Added 19/09/04)
This is an optional step, u'd need it if u want resize images not only using max width value as dimention but also max height.
Install atleast Step 1.x from this fix:
[FIX] Max height has no affect when do image resize


Video tutorial for this mod:
http://www.asian-lady.org/tutors/resize-mod/resize-mod.html


Changes log

v2.0.1 (2010-12-18)
* Fixed: thumbnails not being resized by non-admins (re-do Step 2)

v2.0 (2010-12-12)
+ Added: thumbnails resize (more info and upgrade instructions here)

v1.0 (2004-??-??)
- First release


* install_autoimage.zip (1.84 KB - downloaded 3090 times.)
« Last Edit: December 18, 2010, 07:11:20 PM by V@no » Logged

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)
knuckles
Pre-Newbie

Offline Offline

Posts: 5

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #1 on: February 20, 2003, 04:50:09 AM »

/home/virtual/site56/fst/var/www/html/platinum/gallery/admin/settings.php on line 311

Line 311 is: show_setting_row("auto_image_quality");

But it looks fine, it must be cascading from somewhere else.
Logged
knuckles
Pre-Newbie

Offline Offline

Posts: 5

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #2 on: February 20, 2003, 04:56:01 AM »

Had to write the following two lines by hand:

show_setting_row("auto_image", "radio");
show_setting_row("auto_image_quality");

one of them had/has hidden chars that where affecting the script.

Thanks!
Logged
Chris
4images Moderator
4images Guru
*****
Offline Offline

Posts: 4487

Thank You
-Given: 0
-Receive: 31

Did u ever stop to think and then forget to start?


View Profile
« Reply #3 on: February 20, 2003, 06:38:28 AM »

Quote from: V@no   [Expand]
This MOD will resize uploaded by users images to Max. Image Width set in settings.

Question:

I'm assuming this means it will scale down images that exceed the width/height setting and not scale up images that are smaller than the settings.  

Is this correct?
Logged

V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 565

mmm PHP...


View Profile WWW
« Reply #4 on: February 20, 2003, 06:45:36 AM »

yes, that's correct, the script checks first if image bigger then max width or height, then resize it if so.
Logged

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)
SLL
Hero Member
*****
Offline Offline

Posts: 585

Thank You
-Given: 0
-Receive: 2


View Profile
« Reply #5 on: February 20, 2003, 09:09:32 AM »

Very good idea, V@no! According to my experience, just 10% of users have some idea how to resize their images, so if they're trying to upload oversized photos, and gallery doesn't accept it, they just give up...
Logged
IngoT
Newbie
*
Offline Offline

Posts: 49

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #6 on: February 21, 2003, 12:58:48 AM »

Hallo V@ano,

I have an error message. This error is not always. Mostly with large pictures.

Warning: imagecreatefromjpeg: './data/media/4/168-6875_IMG.JPG' is not a valid JPEG file in /homepages/8/d13361873/htdocs/digitalfotograf/bilderkiste/includes/image_utils.php on line 71


Warning: imagecreatefromjpeg: './data/media/4/168-6875_IMG.JPG.bak' is not a valid JPEG file in /homepages/8/d13361873/htdocs/digitalfotograf/bilderkiste/includes/image_utils.php on line 71


Here cut out of the lines 67 - 75:

else {
    $thumb = imagecreate($width, $height);
  }
  $image_create_handle = "imagecreatefrom".$types[$image_info[2]];
  if ($image = $image_create_handle($src)) {
    if (defined('CONVERT_IS_GD2') && CONVERT_IS_GD2 == 1) {
      imagecopyresampled($thumb, $image, 0, 0, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
    }
    else {


Do you have a solution for the problem?

CU Ingo.
Logged
Ernesto Taseffa
Full Member
***
Offline Offline

Posts: 151

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #7 on: February 26, 2003, 04:37:57 PM »

.
« Last Edit: August 09, 2009, 01:14:16 AM by Ernesto Taseffa » Logged
tradertt
Jr. Member
**
Offline Offline

Posts: 61

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #8 on: February 28, 2003, 06:22:18 PM »

I am getting the same error too ... Although installed the mod but cannot work ... it seems that any thing that deals with converting of images .. there is a problem between windows and unix ...
Logged
V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 565

mmm PHP...


View Profile WWW
« Reply #9 on: February 28, 2003, 10:25:43 PM »

Quote from: tradertt   [Expand]
I am getting the same error too ... Although installed the mod but cannot work ... it seems that any thing that deals with converting of images .. there is a problem between windows and unix ...

can u do any image manipulations from admin control panel? if not, then ask your host what wrong, it's really nothing to do with the script itself.
Logged

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)
Ernesto Taseffa
Full Member
***
Offline Offline

Posts: 151

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #10 on: February 28, 2003, 11:20:11 PM »

.
« Last Edit: August 09, 2009, 01:13:56 AM by Ernesto Taseffa » Logged
V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 565

mmm PHP...


View Profile WWW
« Reply #11 on: March 01, 2003, 01:04:15 AM »

yes, that how this mod works...that was the simpliest way to do...:S

give me the alghoritm how to fix it, I'll fix the code Wink
Logged

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)
tradertt
Jr. Member
**
Offline Offline

Posts: 61

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #12 on: March 01, 2003, 05:46:59 AM »

Quote from: V@no   [Expand]
Quote from: tradertt   [Expand]
I am getting the same error too ... Although installed the mod but cannot work ... it seems that any thing that deals with converting of images .. there is a problem between windows and unix ...

can u do any image manipulations from admin control panel? if not, then ask your host what wrong, it's really nothing to do with the script itself.


Yes I can .. I can do the Auto Image Resize from my admin panel ... the one that is manually done .. but weird is cannot use your mod ...
Logged
tradertt
Jr. Member
**
Offline Offline

Posts: 61

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #13 on: March 01, 2003, 05:50:20 AM »

Quote from: seffern   [Expand]
Hi V@no,

do you sleep also sometime?  Question

I forgot to post today that I did not turned the "auto-resize-function" on in admin menu. I guess this was the reason for the error code above from 26.2.2003, since it disappeared...

So the current status is the one of this morning in the other thread. It resizes automatically the images, which exceed the max. restriction in the admin-menu.

But as far as I remember it just looks at the width restriction, not at the height restriction.

Dirk


Is there such a function to turn on in the admin menu? I cannto find the auto resize function ...
Logged
V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 565

mmm PHP...


View Profile WWW
« Reply #14 on: March 01, 2003, 09:38:49 AM »

Quote from: tradertt   [Expand]

Is there such a function to turn on in the admin menu? I cannto find the auto resize function ...

huh?
if u can not find that in the settings, then, no wonder it doesnt work.... Confused
check again step-by-step instructions.
Logged

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)
Pages: [1] 2 3 4 5 ... 33 » »» Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.112 seconds with 19 queries.