Advertisement:
NameCheap

Author Topic: Resize Attached Images (Updated for 2.0 RC4)  (Read 62095 times)

Offline Kays

  • Customizer
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Resize Attached Images
« Reply #80 on: April 07, 2010, 09:44:55 AM »
It only happens with new images. From what I can see so far is that it does get resized to a jpeg. But after that it get's changed to a .png. If I resize the .png as an existing image it will resize as a jpeg this time.

One temporary solution until i find a fix. In Post.php look for the following and either comment it out or remove it.

Code: [Select]
// Added for the Image resize mod
if(list ($width, $height, $type) = @getimagesize($_FILES['attachment']['tmp_name'][$n]))
{
if($type != 'IMAGETYPE_JPEG' || $width > $modSettings['max_image_width'] || $height > $modSettings['max_image_height'])
{
// What size should this image be?
$width = $width > $modSettings['max_image_width'] ? $modSettings['max_image_width'] : $width;
$height = $height > $modSettings['max_image_height'] ? $modSettings['max_image_height'] : $height;

// Resize it
require_once($sourcedir . '/Subs-Graphics.php');
if(saveAsJpeg($_FILES['attachment']['tmp_name'][$n], $width, $height, $_FILES['attachment']['tmp_name'][$n]))
{
// Find the new size.
$_FILES['attachment']['size'][$n] = filesize($_FILES['attachment']['tmp_name'][$n]);

// Change the file name if it's not a .jpg
if(strrchr($_FILES['attachment']['name'][$n], '.') != '.jpg')
$_FILES['attachment']['name'][$n] = substr($_FILES['attachment']['name'][$n], 0, -(strlen(strrchr($_FILES['attachment']['name'][$n], '.')))) . '.jpg';
}
}
}
// End Image resize mod
 

This will resize any images when they are viewed rather than when uploaded.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Offline Makar

  • Semi-Newbie
  • *
  • Posts: 75
    • Портал у Завгара
Re: Resize Attached Images
« Reply #81 on: April 07, 2010, 01:27:19 PM »
thanks try
I'll write about the results

Sorry for my english

Offline hellbent64

  • Semi-Newbie
  • *
  • Posts: 48
Re: Resize Attached Images
« Reply #82 on: April 07, 2010, 09:07:45 PM »
so my forums has been acting buggy for awhile now...  i think ultimate shoutbox buggered something up.
found out today i have 6584 pages of attachment thumbnails and found out its this conflict with highslide and 1.1 of resize.

well i uploaded and ran the clean_thumbs.php and get this error:
Fatal error: Cannot redeclare ssi_shout() (previously declared in D:\Hosting\4508226\html\APforums\SSI.php:1571) in D:\Hosting\4508226\html\APforums\SSI.php on line 1585

i tried uninstalling shoutbox but i still get this error.
i am running
SMF Package SMF 1.1.11

any advice for me?

Offline Kays

  • Customizer
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Resize Attached Images
« Reply #83 on: April 07, 2010, 09:38:57 PM »
Take a look in SSI.php at those mentioned lines and you'll probably see some code for the shoutbox which is duplicated. Since you have the shoutbox removed, you should be safe to remove all of that code.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Offline hellbent64

  • Semi-Newbie
  • *
  • Posts: 48
Re: Resize Attached Images
« Reply #84 on: April 08, 2010, 04:24:13 AM »
sorry, i dont know much about php.   i removed the lines and it cleared up about 59000 images!
thanks!

Offline Makar

  • Semi-Newbie
  • *
  • Posts: 75
    • Портал у Завгара
Re: Resize Attached Images
« Reply #85 on: April 08, 2010, 01:20:41 PM »
One temporary solution until i find a fix..................

as a temporary solution came
but
had to increase the limit from 206 kb to 1024kb for one picture
otherwise the image is larger than 206kb does not load and resize

Sorry for my english

Sorry for my english

Offline hotrod007

  • Jr. Member
  • **
  • Posts: 149
    • NJ Saltwater Fishing
Re: Resize Attached Images
« Reply #86 on: April 20, 2010, 07:44:34 AM »
I'm Getting this Error on a couple pages.  SMF 1.1.11

http://njsaltwaterfisherman.com/forums/index.php?topic=15031.160

Code: [Select]
Database Error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Custom Plugs.jpg'
WHERE ID_ATTACH = 26752
LIMIT 1' at line 2
File: /var/www/vhosts/njsaltwaterfisherman.com/httpdocs/forums/Sources/Display.php
Line: 1229

Note: It appears that your database may require an upgrade. Your forum's files are currently at version SMF 1.1.11, while your database is at version 1.1.1. The above error might possibly go away if you execute the latest version of upgrade.php.

Also my error log is filled with Errors.. like this.


Code: [Select]
Apply Filter: Only show the errors with the same message
Attachment not found: /var/www/vhosts/njsaltwaterfisherman.com/httpdocs/forums/attachments/27483_ad8364f6c47f6ed32ee3cf87817d1e762a63d6b3

Code: [Select]
Apply Filter: Only show the errors with the same message
2: imagejpeg() [<a href='function.imagejpeg'>function.imagejpeg</a>]: Unable to open '/var/www/vhosts/njsaltwaterfisherman.com/httpdocs/forums/attachments/14237_SGtogSP10707_jpg41e51d95dde49d647d2eb03e69ba5718' for writing
File: /var/www/vhosts/njsaltwaterfisherman.com/httpdocs/forums/Sources/Subs-Graphics.php
Line: 1732


I am Afraid what will happen if I uninstall this mode now... :-[

Offline Kays

  • Customizer
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Resize Attached Images
« Reply #87 on: April 20, 2010, 09:12:26 AM »
Removing the mod might or might not get rid of that error. It looks like that file is missing in the attachments folder.

In the Admin CP > Attachments and Avatars > File Maintenance. At the end of this line Total Size of Attachment Directory is a [Maintain] link. Click on that and run any suggested tasks.

Also, it appears that your database is way outdated. Download the large upgrade package, extract the upgrade.php and the .sql files and upload them to the root of your forums. Then run upgrade.php. Do backup your database first before doing so.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Offline hotrod007

  • Jr. Member
  • **
  • Posts: 149
    • NJ Saltwater Fishing
Re: Resize Attached Images
« Reply #88 on: April 20, 2010, 09:47:33 AM »
I did as you said.  but the Script to maintain has been running for the last 15 minutes..

Not done yet!
To avoid overloading your server, the process has been temporarily paused. It should automatically continue in a few seconds. If it doesn't, please click continue below.

I never had the data base error before..  Do we think the resizer is what caused it because of the old version?

I never updated the data base version.. didn't know I needed to..

I love this mode. I hope I get get this worked out.

I'm afraid of these updates.. always worried I'm going to lose something..

Where do I find the update script..



Edit.  I removed the Mod.  and everything is back to norm..  I would like to try and the the update and then reinstall it.  Maybe it will then run right?
« Last Edit: April 20, 2010, 10:09:39 AM by hotrod007 »

Offline Kays

  • Customizer
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Resize Attached Images
« Reply #89 on: April 20, 2010, 10:09:19 AM »
It might take a little while to run but not that long I would think.

Since 1.1.1 there have been several changes made to the database. Some of it to do with attachments. But the mod should work fine on older versions.

As for updating, you can download the large  upgrade package from here. All that's required from it are the upgrade.php and the .sql files. I think there's two of them.

Do backup your database first. (How do I backup my database?)
 

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Offline hotrod007

  • Jr. Member
  • **
  • Posts: 149
    • NJ Saltwater Fishing
Re: Resize Attached Images
« Reply #90 on: April 20, 2010, 10:19:30 AM »
Thanks Kays for your help..  My Host is backing up everything.  I'll run the update tonight.. then reinstall and see what happens.. I love this Mod. I hope I can get it to work.

So When I did the automatic updating from my old version.  This PHP File wasn't included..?

« Last Edit: April 20, 2010, 10:28:29 AM by hotrod007 »

Offline Kays

  • Customizer
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Resize Attached Images
« Reply #91 on: April 20, 2010, 10:48:35 AM »
When an auto update is run the database upgrade should be a part of the process. But it looks like that got skipped in your case.

Did that maintenance routine finally finish running?

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Offline hotrod007

  • Jr. Member
  • **
  • Posts: 149
    • NJ Saltwater Fishing
Re: Resize Attached Images
« Reply #92 on: April 20, 2010, 11:57:55 AM »
No  I ran it again after removing the Mod.  and it still hung for 10 minutes..

Updates scare me :P

Offline Kays

  • Customizer
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Resize Attached Images
« Reply #93 on: April 20, 2010, 12:02:48 PM »
Without the mod, are you still getting those errors now?

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Offline hotrod007

  • Jr. Member
  • **
  • Posts: 149
    • NJ Saltwater Fishing
Re: Resize Attached Images
« Reply #94 on: April 20, 2010, 01:00:08 PM »
NO All cleaned up.  that link I post with that Error.   The post was actually missing. and the images.
when I removed the mod.  the post and images came back and all errors are gone now.

I really need this Mod.  My members aren't very good at resizing.. :o
« Last Edit: April 20, 2010, 02:50:18 PM by hotrod007 »

Offline Kays

  • Customizer
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Resize Attached Images
« Reply #95 on: April 23, 2010, 11:13:19 PM »
Hi, sorry about the delay. I've updated it for 1.x and hopefully this should correct you problems.


Updated for 2.0 RC3

Due to a number of problem with attachments in 2.0 RC3 and the changes I have done a major rewrite of the mod and updated to to address a numbers of problems associated with image files. Some of the fixes include.

 - White screen of death when uploading larger files
 - Reencoded images now preserve the file format.
 - Disabled duplicate file name checking.
 -  Added a warning message if GD is not available.
 - Better support for bitmap images.

Features added in the Attachment settings in the Admin CP.
 - The ability to set a max width and height for attached images separately rather than using the values for posted images
 - The ability to set the jpeg compression factor.
 - The option to save thumbnail either as .jgp or .png. independent of the avatar setting.
 - Change existing  .png images back to .jpg.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Offline hotrod007

  • Jr. Member
  • **
  • Posts: 149
    • NJ Saltwater Fishing
Re: Resize Attached Images (Updated for 2.0 RC3 with bug fixes)
« Reply #96 on: April 23, 2010, 11:43:22 PM »
Cool Kay..  this may correct My? Problem..  I'm afraid to do the Database update.. :-\

Offline Bugo

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,446
  • Gender: Male
    • @dragomano on Twitter
    • Review & translation for SMF mods
Re: Resize Attached Images (Updated for 2.0 RC3 with bug fixes)
« Reply #97 on: April 24, 2010, 02:25:15 AM »
Russian translation (look at attachments) for ANSI & UTF-8 charsets.

Offline Spuds

  • SMF Hero
  • ******
  • Posts: 1,798
  • Gender: Male
Re: Resize Attached Images (Updated for 2.0 RC3 with bug fixes)
« Reply #98 on: May 05, 2010, 12:26:22 PM »
Kays,

Awesome mod, just what I needed with users that rather upload a large image and let the forum do the resize work, those 10 megapixel cameras and fast internet access have really change the way people interact with forums and this mod is needed.

While doing some testing (RC3) I uploaded a large image, 2592x1944 about 2.2M, and had the admin settings of max width and max height set to 1024.   When the file uploaded it was resized but to 1365x1024 (and now 200K sweet).  Anyway I was surprised by the 1365 dimension since I had set a max to 1024.

Offline Kays

  • Customizer
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Resize Attached Images (Updated for 2.0 RC3 with bug fixes)
« Reply #99 on: May 07, 2010, 11:23:14 PM »
Hi Spuds. thanks for that. It looks like there was a problem with the script. I've corrected that

Thanks for the translation Bugo. It has been added.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods