Resize Attached Images (Updated for 2.0 RC4)

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

Previous topic - Next topic

Kays

I couldn't reproduce that problem on 2.0 and didn't check it on a 1.1 forum. I'll do that later when I get a chance.

Are the file names as you described earlier?  1050_IMG_4355_resize_jpg2a1fcff297c2c737ddc2e5389abd5196

Do you see them in the database?

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

avf

i see them in the attachments table as follows

44890     0     18949     0     3     abc.jpg_thumb     7348     0     130     200     e99b1e88ec51848a30f04b6d13b1cb07699dc2d4
   Edit    Delete    44889    44890    18949    0    0    abc.jpg    42826    1    390    600    911720651ba39007e9cc7f654d0c0b6769913d88

the files are named 44890_e99b1e88ec51848a30f04b6d13b1cb07699dc2d4

Kays

I can't seem to reproduce this problem on a 1.1.10 forum.


44890     0     18949     0     3     abc.jpg_thumb     7348     0     130     200     e99b1e88ec51848a30f04b6d13b1cb07699dc2d4
44889    44890    18949    0    0    abc.jpg    42826    1    390    600    911720651ba39007e9cc7f654d0c0b6769913d88


This is normal for the database entries. The second entry is the original image and the first one is the thumb. Since SMF 1.1.9, the files in the attachments folder are now named as such:

44889_911720651ba39007e9cc7f654d0c0b6769913d88
44890_e99b1e88ec51848a30f04b6d13b1cb07699dc2d4


With the file id followed by the file hash.


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

lala1

Hello!

Great mod, I've been looking for this feature for a long time now. There is one problem though, since I'm running a forum where users display lots of images per thread (40-50 sometimes), it takes a very long time for the server to resize the images and it seems to me that it is doing it every time a page is being accessed.

Is there an option that I'm constantly missing and that would allow the server to resize the images once for good?

Kays

Hi, this mod does only resiize the image once.

With that many images on a page it will take some time for all of the thumbnails to be loaded. Old thumbnails might be .png files which at times can be of a larger file size than the .jpg image. Depending on the size of the thumbnails.

Re-sizing the thumbnails will force new ones to be created which are .jpg. But also may leave extra files on the server which can be removed with that script I posted earlier.

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

lala1

All the thumbnails on that forum are jpg for a long time now. Still, when accessing a thread with multiple images attachments IF this mod is active, it takes the browser about 2 minutes to display the page. Upon refreshing the same page, same thing occurs. But if I disable this mod, things speed up considerably (less than 30 seconds).

I'm using highslide viewer also, but I disabled it and same thing occurs. Might be some checkup?

Thanks,
lala

Kays

I did verify that the mod only resized once before making that statement. So I'm a bit baffled

Which version of the mod are you using? And which version SMF?

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

lala1

Resize Attached Images v1.3
SMF 2.0 RC2
Host: Dreamhost

It might be some checkup that the script is performing upon accessing a page.

Thanks for your support :)
lala

samurai-lupin

Hello, I have just updated this great mod and wanted to remove my duplicate thumbnails but received this error when running your script:

Unknown column 'file_hash' in 'field list'
File: /home/atanua/public_html/smf/clean_thumbs.php
Line: 127

I'm using 1.1RC2

Unfortnately by creaiting double thumbnails by inodes have risedn to close to 80.000 in my attachments folder.

Any help is appreciated.

Thank you!

Kays

@samurai-lupin
I would strongly recomend that you upgrade to 1.1.10 due to a number of security fixed which have been implimended.

Open clean_thumbs.php and on line 122 remove the ", file_hash" so that line now looks like


SELECT filename, ID_ATTACH


That should get it to run.

@lala1
Sorry about the delay. 

if you wish to check if this mod is causing the slow down. with the mod installed, open Sources/Display.php

Look for:


// Find the new dimensions and size


and above it add:


log_error('Image resized - ' . $attachment['filename']);


then look for:


// So what folder are we putting this image in?


And above it add:


log_error('Thumb resized - ' . $attachment['filename']);


Doing this will add an entry to the error log, assuming that it is enabled, every time an image is resized or a new thumbnail is created. If the mod is functioning correctly, you should not see any items repeated.

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

samurai-lupin

Quote from: Kays on November 24, 2009, 06:59:09 AM
@samurai-lupin
I would strongly recomend that you upgrade to 1.1.10 due to a number of security fixed which have been implimended.

Open clean_thumbs.php and on line 122 remove the ", file_hash" so that line now looks like


SELECT filename, ID_ATTACH


That should get it to run.


Thank you. What about the id_folder?

Should it be
         SELECT filename, id_attach, id_folder

or?

         SELECT filename, id_attach

Thanks a lot!

Kays

No, look further down. That is for 2.0.

"ID_ATTACH" should be upper case since you are using SMF 1.1

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

samurai-lupin

#32
ATTENTION ALL - DO NOT USE THIS MOD OR ESPECIALLY NOT THE clean-thumbs.php BY ANY MEANS!!! I JUST DID SO AND IT DELETED ALL MY ATTACHMENTS !!! THIS THIBG WILL KILL YOUR FORUM AND IS NOT WORKING!!! BEWARE!!!

IT CAUSED TREMENDOUS DAMAGE TO MY FORUM! THIS MOD HAS TO BE DELETED!!!

lala1

@samurai-lupin: this was a stupid thing to do. this guy really supports his mods; more than that you should have made backups, but hey, the smartest thing to do is to yell here, isn't it?

@Kays: thanks for support, I will check that as soon as possible. Keep up the good work and ignore the rest!

samurai-lupin

Lala, if you install a mod reported to be safe and then it almost kills your forum I'm sure you would be happy as you are a most smart person. I hope you will get the chance to enjoy this situation at some point in the future.

Arantor

samurai-lupin: Please edit your above post to resize the font.

I tested this mod pretty thoroughly, and could not make it do what you are saying it did.

samurai-lupin

Unfortunately it really does and the mod author has aggreed to this as well. I wish it was different. However the mod author has said he would fix th problem. Once he has I will remove my posting. Meanwhile I would urge anybody using a pre 1.1.4 installation not to use this mod.

Arantor

I would hope few people don't use forums that old now due to numerous security issues. I would also ensure the directions given in the package manager are followed, i.e. "make sure you have backups".

When I originally reviewed this mod, clean-thumbs.php did not exist; we also do not do period reviews, though after the unsafe report I still couldn't get this to misbehave.

Kays

samurai-lupin, as I indicated in PM, the problem was not with the clean_thumbs script but rather with the mod and the version of SMF which you are using. As well, it didn't break your forum since the only files affected were the ones with .JPG in uppercase.

I have offered to correct the problem, but so far have not received any reply from you either in the form of a reply PM or removal or edit of that post.

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

Norv

Quote from: samurai-lupin on November 30, 2009, 08:00:20 AM
Meanwhile I would urge anybody using a pre 1.1.4 installation not to use this mod.

Nobody should be using such an outdated version. There were security vulnerabilities found meanwhile, which put all your data in danger, not only some. IMHO, I would not expect mod authors to have their mods tested on any outdated version of SMF, that would be a lot of work for no real benefit. Sorry.
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

Advertisement: