Advertisement:

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

Offline Kays

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Resize Attached Images (Updated for 2.0 RC4)
« on: October 17, 2009, 04:19:10 PM »
Link to Mod

Automatically resizes attached images to the same dimensions as for posted images.

This mod will resize all attached .jpg, .png, .gif, or .bmp images save them as .jpg. Either as they are being uploaded, or for existing images, when they are viewed. As well, any existing .png, .gif, or .bmp images will be converted to .jpg.

Note:

Due to a problem with the mod creating extra thumbnails. I would advise anyone using V1.1 to update to V1.2. As well, upload this script the root of your forums and access it by url to clean up any extra thumbnails

V1.1 Initial release
V1.2 Fixed a bug where extra thumbnails were created
V1.3 Updated for SMF 2.0
V1.4 Fixed a bug with files not being renamed if encrypted file names was enabled before SMF 1.1.9 or 2.0 RC1.1.
V1.5 Minor fixes


V2.0
 
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.

V2.0.1 Added Russian & Russian-utf8. Thanks to Bugo.
V2.1.1 Fixed a bug with the width on resized images.
V2.2.1 Updated for 2.0 RC4
« Last Edit: January 18, 2011, 10:00:12 PM by Kays »

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

Offline gourav

  • Semi-Newbie
  • *
  • Posts: 77
  • Gender: Male
Re: Resize Attached Images
« Reply #1 on: October 19, 2009, 02:09:49 PM »
Hey dear great mod :) i was in search of something like this
Well can you clear out one thing , Will this mod resize the images
everytime it will be loaded or it will permanently replace the uploade
i.e. will Resize ythe original pic forever?

and can v manually choose the resize dimensions

Offline Kays

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Resize Attached Images
« Reply #2 on: October 19, 2009, 07:44:24 PM »
Hi, this mod is for those who wish to cut down on server space. So it does permanently resize all attached images.

The settings are the same as for posted images. Admin CP > Features and Options > Max width of posted pictures, Max height of posted pictures

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

Offline ddarrell

  • Semi-Newbie
  • *
  • Posts: 53
  • Gender: Male
Re: Resize Attached Images
« Reply #3 on: October 19, 2009, 08:31:39 PM »
Very nice, Thank You.

Successful install on 1.1.10.

 :)
 
i know just enough to really screw up ;D

Offline avf

  • Semi-Newbie
  • *
  • Posts: 79
Re: Resize Attached Images
« Reply #4 on: October 30, 2009, 04:44:17 PM »
I installed on SMF  but strangely the attachment folder has swelled upto 44000 files and 500MB with
names like

1536_164d9fd9aa92e415a370338257c4031f54fdd2a1
1047_IMG_4352_resize_jpg0ae79bd3f4292253353258c7b2b93b2a
1050_IMG_4355_resize_jpg2a1fcff297c2c737ddc2e5389abd5196

can you tell if it is duplicating the files or what is happening. I don't have that many attachments in my forum. Please advice I am running out of space on my server.

It appears to have created a huge number of small files upto 10kb on just one day so I know they are not new attachments and the total seems to have jumped from 2000 odd attachments to 44000 now.

I am also using the highslide viewer mod. is it causin the image to be resized multiple times as it is viewed ? this mod http://custom.simplemachines.org/mods/index.php?mod=1450
« Last Edit: October 30, 2009, 05:14:59 PM by avf »

Offline Kays

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Resize Attached Images
« Reply #5 on: October 30, 2009, 05:07:56 PM »
1536_164d9fd9aa92e415a370338257c4031f54fdd2a1 is the proper format for attached files. I don't know where the others are coming from.

Do you have any other mods installed which affect attachments?


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

Offline avf

  • Semi-Newbie
  • *
  • Posts: 79
Re: Resize Attached Images
« Reply #6 on: October 30, 2009, 05:15:53 PM »
It appears to have created a huge number of small files upto 10kb on just one day so I know they are not new attachments and the total seems to have jumped from 2000 odd attachments to 44000 now.

I am also using the highslide viewer mod. is it causin the image to be resized multiple times as it is viewed ? this mod http://custom.simplemachines.org/mods/index.php?mod=1450

Offline Kays

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Resize Attached Images
« Reply #7 on: October 30, 2009, 06:55:46 PM »
It doesn't look like it's that mod.

Do you see them in the Admin CP when viewing the attachements?

If you have database access, do you see them in the attachments table. The first numbers of a file name before the first underscore (_) is the attachment id. You should be able to use that if checking the database or look for a repitition of this in the file names.

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

Offline avf

  • Semi-Newbie
  • *
  • Posts: 79
Re: Resize Attached Images
« Reply #8 on: October 31, 2009, 02:06:16 AM »
Here is what is happening. I disabled the highslide viewer mod and uploaded a pic. The attachments table showed me 44673 rows after the upload and I saw my image had been uploaded as the last one.

After that i enabled the highslide viewer mod so all images now displayed as thumbs. I clicked on the same thread again to view the last post with image and in the table the number of entires jumped to 44713 and i saw new entries for all images in that thread named xxxxxx.jpg_thumb size(200x200). So I guess all images in the thread opened are instantly resized and renamed as xxx.jpg_thumb.

Once i disable the highslide viewer mod then it doesnt happen. However I do know this did not happen earlier with just the highslide viewer mod and is a conflict with resize image mod and highslide viewer.

Please advice.................
« Last Edit: October 31, 2009, 02:34:57 AM by avf »

Offline avf

  • Semi-Newbie
  • *
  • Posts: 79
Re: Resize Attached Images
« Reply #9 on: October 31, 2009, 05:41:36 AM »
What also i would like to know is Can I delete the rows in the attachments table with files like %.jpg_thumb ? That would clean out 42000 rows. However i am now unable to view the files in the server as my ftp software allows me to view only 2000 files. I want to delete the same files in the attachment folder to reclaim server space.

Offline Kays

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Resize Attached Images
« Reply #10 on: October 31, 2009, 09:24:16 AM »
SMF 1.1 or 2.0?

I'd like to install it on a test forum to see what is happening.

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

Offline avf

  • Semi-Newbie
  • *
  • Posts: 79
Re: Resize Attached Images
« Reply #11 on: October 31, 2009, 11:12:50 AM »
SMF 1.1.10

Offline Kays

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Resize Attached Images
« Reply #12 on: October 31, 2009, 01:35:53 PM »
Thanks. It does look like there's a problem with my mod and it's continually ceating thumbnails.

Please uninstall it until i get a chance to fix the problem. I'll also try to write a utility to clean up the extra thumbnails created.

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

Offline avf

  • Semi-Newbie
  • *
  • Posts: 79
Re: Resize Attached Images
« Reply #13 on: October 31, 2009, 06:09:40 PM »
Thanks. It does look like there's a problem with my mod and it's continually ceating thumbnails.

Please uninstall it until i get a chance to fix the problem. I'll also try to write a utility to clean up the extra thumbnails created.

I have disabled the slide viewer as I would rather have members upload larger files. The extra files created have created a havoc and I have to cleanup almost 44400 files and i cannot even download them as well as view them in FTP s/w. The cleaner QUICKLY would be highly appreciated.
« Last Edit: October 31, 2009, 06:19:59 PM by avf »

Offline Kays

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Resize Attached Images
« Reply #14 on: November 01, 2009, 01:36:00 PM »
Hi, I do have something working. But I've got a concern over the large number of queries involved. Especially in your case.

Could you possibly create a backup of just the attachments table so it can use it for testing?

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

Offline avf

  • Semi-Newbie
  • *
  • Posts: 79
Re: Resize Attached Images
« Reply #15 on: November 01, 2009, 02:11:15 PM »
its not working the backup is more than 500MB and the attachments folder shows me 44700 rows. the problem now is the format of images name is changed from the orignal smf format. even when i updat the files from the eaarlier backup the images are broken in the forum

Offline Kays

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Resize Attached Images
« Reply #16 on: November 04, 2009, 09:39:24 AM »
Hi, sorry about the delay.

Upload the attached file to the root of your forum and access it by url (hxxp://MySite.com/forums/clean_thumbs.php)

I've also uploaded a corrected verson of the mod. Do uninstall the old version and replace it with the new one.

Note:
I'd advise anyone using V1.1 of this mod to uninstall it and install V1.2. Then run the attached script to remove any extra thumbnails created. It willl work for both SMF 1.1 as well as SMF 2.0
« Last Edit: November 04, 2009, 09:42:41 AM by Kays »

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

Offline jeffrey scott

  • Semi-Newbie
  • *
  • Posts: 64
Re: Resize Attached Images
« Reply #17 on: November 04, 2009, 10:39:47 AM »
Hi, sorry about the delay.

Upload the attached file to the root of your forum and access it by url (hxxp://MySite.com/forums/clean_thumbs.php)

I've also uploaded a corrected verson of the mod. Do uninstall the old version and replace it with the new one.

Note:
I'd advise anyone using V1.1 of this mod to uninstall it and install V1.2. Then run the attached script to remove any extra thumbnails created. It willl work for both SMF 1.1 as well as SMF 2.0

How do I run that clean up script Kays?

thanks

Jeff

Offline Kays

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,973
  • Gender: Male
    • Kayssplace
Re: Resize Attached Images
« Reply #18 on: November 04, 2009, 11:07:27 AM »
You upload it to the root of your forum, the same place as SSI.php. Then access it by url  like so: hxxp://MySite.com/forums/clean_thumbs.php

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

Offline avf

  • Semi-Newbie
  • *
  • Posts: 79
Re: Resize Attached Images
« Reply #19 on: November 05, 2009, 02:05:14 AM »
Super awesome ! You have made a great mod and also supported it which is even better. I was so happy to recover almost 500mb of server space after the orphaned files were deleted. Thanks and congrats on this wonderful mod. I think it should be incorporated with the forum itself.

There is still one "issue" i would like to point out. When used with the high slide viewer which basically shows all the images as thumbs and when clicked on expands to show the actual image it is creating 2 images for every upload. One is the actual uploaded one and the other is the thumb image. Is that because of your mod or the high slide viewer ?

AVF