News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Resize Attached Images (Updated for 2.0 RC4)

Started by Kays, October 17, 2009, 04:19:10 PM

Previous topic - Next topic

Kays

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

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

gourav

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

Kays

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

ddarrell

Very nice, Thank You.

Successful install on 1.1.10.

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

avf

#4
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

Kays

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

avf

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

Kays

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

avf

#8
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.................

avf

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.

Kays

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

avf


Kays

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

avf

#13
Quote from: Kays 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.

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.

Kays

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

avf

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

Kays

#16
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

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

jeffrey scott

Quote from: Kays 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

How do I run that clean up script Kays?

thanks

Jeff

Kays

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

avf

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

Advertisement: