Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: Naturforum on January 11, 2006, 12:33:17 PM

Title: Resample Big Attached Images
Post by: Naturforum on January 11, 2006, 12:33:17 PM
Link to Mod (http://mods.simplemachines.org/index.php?mod=252)

If attached image has physical dimensions larger than what is allowed ("Max width/height of posted pictures" on page "Basic Features"), this mod will automatically and permanently resample (shrink) the stored image file so it fits within the maximum dimension limits.

I.e. if the limits are 800x800 pixels and the attached image is 3200x2400 it will be resized to 800x600.

This can greatly reduce the storage space required on the server, without forcing the users to shrink the images themselves.

NB: THIS MOD CURRENTLY REQUIRES GD2 SUPPORT!

NB2: THIS HAS ONLY BEEN TESTED ON A CLEAN INSTALL OF SMF 1.1 RC 1/2
Title: Re: Resample Big Attached Images
Post by: evillair on January 13, 2006, 10:45:22 PM
You wouldn't have a 1.0.5 compatible version? :)
Title: Re: Resample Big Attached Images
Post by: DrilLer on January 14, 2006, 06:41:08 AM
Fatal error: Call to undefined function: exif_imagetype() in /home1/hosting/www.bnet.by/forum/Sources/Post.php on line 1455
Title: Re: Resample Big Attached Images
Post by: e03179 on January 14, 2006, 11:16:57 AM
I'm giving it a spin.  I've needed something like this.
Title: Re: Resample Big Attached Images
Post by: Naturforum on January 15, 2006, 04:38:17 AM
Quote from: evillair on January 13, 2006, 10:45:22 PM
You wouldn't have a 1.0.5 compatible version? :)

Sorry, no.
I have not tried 1.0.5 myself. But I would assume it would be quite easy to adapt to other versions. Download 1.1RC2, take a look at my mod file, at the file it modifies, and at the 1.0.5 version of that file. Maybe you'll be able to make it 1.0.5 compatible.
Title: Re: Resample Big Attached Images
Post by: Naturforum on January 15, 2006, 04:39:44 AM
Quote from: DrilLer on January 14, 2006, 06:41:08 AM
Fatal error: Call to undefined function: exif_imagetype() in /home1/hosting/www.bnet.by/forum/Sources/Post.php on line 1455

This mod has only been tested on a clean install of SMF 1.1 RC1/2, on a server supporting various graphics related functions.

My first guess would be that the PHP-installation on your server has not been compiled with exif-support.

Check this using phpinfo(). Look for the string "--enable-exif" in "Configure Command".

If this is not present the mod will probably not work.
Title: Re: Resample Big Attached Images
Post by: xtremecruiser on January 17, 2006, 06:18:06 PM
Worked fine after I set the limits to 800x800 pixels, would not work with 800x600 ???
On a upgraded forum SMF 1.1 RC2
Title: Re: Resample Big Attached Images
Post by: Bigguy on January 17, 2006, 10:49:32 PM
If you already have images on your forum will it resize them as well ??? or will it just resize new images that have been put on the forum since the mod was installed.
Title: Re: Resample Big Attached Images
Post by: xtremecruiser on January 19, 2006, 05:24:54 PM
Quote from: Bigguy on January 17, 2006, 10:49:32 PM
If you already have images on your forum will it resize them as well ??? or will it just resize new images that have been put on the forum since the mod was installed.
Only the ones you UL after the mod, at least on mine
Title: Re: Resample Big Attached Images
Post by: Bigguy on January 20, 2006, 03:48:36 PM
Thanks for the info :)
Title: Re: Resample Big Attached Images
Post by: gravy on January 23, 2006, 12:23:27 AM
Quote from: evillair on January 13, 2006, 10:45:22 PM
You wouldn't have a 1.0.5 compatible version? :)

I changed the package-info.xml codes a little like so:
<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<id>resample_big_attached_images</id>
<name>Resample Big Attached Images</name>
<version>0.1</version>
<type>modification</type>
<install for="1.1 RC1, 1.1 RC2, 1.1">
  <readme type="inline">Install mod Resample Big Attached Images</readme>
  <modification format="boardmod" type="file">resample_big_attached_images.mod</modification>
</install>
<uninstall for="1.1 RC1, 1.1 RC2, 1.1">
  <readme type="inline">Thanks for trying out this mod.</readme>
  <modification format="boardmod" type="file" reverse="true">resample_big_attached_images.mod</modification>
</uninstall>
</package-info>


to:

<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<id>resample_big_attached_images</id>
<name>Resample Big Attached Images</name>
<version>0.1</version>
<type>modification</type>
<install for="1.1 RC1, 1.1 RC2, 1.0.5">
  <readme type="inline">Install mod Resample Big Attached Images</readme>
  <modification format="boardmod" type="file">resample_big_attached_images.mod</modification>
</install>
<uninstall for="1.1 RC1, 1.1 RC2, 1.0.5">
  <readme type="inline">Thanks for trying out this mod.</readme>
  <modification format="boardmod" type="file" reverse="true">resample_big_attached_images.mod</modification>
</uninstall>
</package-info>

Uploaded the package and everything worked fine! Even resized all of my attachments from previous posts. Hope it helps ya out.
Title: Re: Resample Big Attached Images
Post by: xtremecruiser on January 23, 2006, 06:12:54 PM
Seems just a mod so it works with 1.05
It resized all your old UL's too ?
I installed it on 2 different forums and it did not resize the old UL's ???

Quote from: gravy on January 23, 2006, 12:23:27 AM
Quote from: evillair on January 13, 2006, 10:45:22 PM
You wouldn't have a 1.0.5 compatible version? :)

I changed the package-info.xml codes a little like so:
<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<id>resample_big_attached_images</id>
<name>Resample Big Attached Images</name>
<version>0.1</version>
<type>modification</type>
<install for="1.1 RC1, 1.1 RC2, 1.1">
  <readme type="inline">Install mod Resample Big Attached Images</readme>
  <modification format="boardmod" type="file">resample_big_attached_images.mod</modification>
</install>
<uninstall for="1.1 RC1, 1.1 RC2, 1.1">
  <readme type="inline">Thanks for trying out this mod.</readme>
  <modification format="boardmod" type="file" reverse="true">resample_big_attached_images.mod</modification>
</uninstall>
</package-info>


to:

<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<id>resample_big_attached_images</id>
<name>Resample Big Attached Images</name>
<version>0.1</version>
<type>modification</type>
<install for="1.1 RC1, 1.1 RC2, 1.0.5">
  <readme type="inline">Install mod Resample Big Attached Images</readme>
  <modification format="boardmod" type="file">resample_big_attached_images.mod</modification>
</install>
<uninstall for="1.1 RC1, 1.1 RC2, 1.0.5">
  <readme type="inline">Thanks for trying out this mod.</readme>
  <modification format="boardmod" type="file" reverse="true">resample_big_attached_images.mod</modification>
</uninstall>
</package-info>

Uploaded the package and everything worked fine! Even resized all of my attachments from previous posts. Hope it helps ya out.
Title: Re: Resample Big Attached Images
Post by: Naturforum on January 28, 2006, 10:54:37 AM
Quote from: xtremecruiser on January 23, 2006, 06:12:54 PM
Seems just a mod so it works with 1.05
It resized all your old UL's too ?
I installed it on 2 different forums and it did not resize the old UL's ???

I have not tested it on 1.0.5 so if it works there without altering it's just by luck..  ;D

To my knowledge it does not affect existing images, only the ones uploaded subsequent to installing the mod.
Title: Re: Resample Big Attached Images
Post by: mediman on April 19, 2006, 07:13:31 AM
Quote from: Naturforum on January 15, 2006, 04:39:44 AM
This mod has only been tested on a clean install of SMF 1.1 RC1/2, on a server supporting various graphics related functions.

My first guess would be that the PHP-installation on your server has not been compiled with exif-support.

Check this using phpinfo(). Look for the string "--enable-exif" in "Configure Command".

If this is not present the mod will probably not work.


has nothing to do with php or exif. the problem is that this mod uses the exif infos to check the images sizes and not all images have this infos.

it would be quite better to use the inbuild gd2 function to check the width and height of an image.

mediman
Title: Re: Resample Big Attached Images
Post by: ccondrup on October 30, 2006, 08:23:39 AM
Hello, I am also receiving that same error (undefined function: exif_imagetype()), and I know my host has both GD2 and Exif support, but I noticed php has not been compiled --enable-exif. I am not sure whether another method has been used, but see these screens that show exif and gd is enabled: (http://bildr.no/thumb/17384.jpeg) (http://bildr.no/view/17384) (http://bildr.no/thumb/17385.jpeg) (http://bildr.no/view/17385)

What mediman says here makes sense - but is someone willing to look into it and maybe update this mod with a more clever version of checking attached images, and also update for Rc3 while at it?

I would guess there are lots of administrators out there that have limited webspace and still would like to offer uploading to users...  Digital cameras keeps on delievering larger and larger images, and users put the originals up on the forums.... gargh... please help, thanks!
Title: Re: Resample Big Attached Images
Post by: kriskd on December 30, 2006, 07:37:16 AM
Is this compatible with 1.1.1 and how can we determine if we have GD2 support?
Title: Re: Resample Big Attached Images
Post by: Stirred on January 08, 2007, 03:31:15 PM
I manage to put it working with 1.1.1 with 1024x1024, but i still get some errors:

Quote2: exif_imagetype(post_tmp_791_2) [<a href='function.exif-imagetype'>function.exif-imagetype</a>]: failed to open stream: No such file or directory
Ficheiro: /home/hentaip/public_html/Sources/Post.php
Linha: 1495

and

Quote2: imagesx(): supplied argument is not a valid Image resource
Ficheiro: /home/hentaip/public_html/Sources/Post.php
Linha: 1506

Would be nice if anyone could fix those errors. But apparently it doesn´t has any problems besides appearing on error log.
Title: Re: Resample Big Attached Images
Post by: xtremecruiser on January 08, 2007, 03:43:26 PM
Just go into the package-info.xml file and add 1.1.1 to 2 lines
<install for="1.1 RC1, 1.1 RC2, 1.1, 1.1.1, 1.1.2 ">
<uninstall for="1.1 RC1, 1.1 RC2, 1.1, 1.1.1, 1.1.2">

and it works fine

Updated to work with 1.1.2 ( just make the chages above )
Title: Re: Resample Big Attached Images
Post by: BjornB on March 02, 2007, 02:19:40 AM
Doesn't work with 1.1.2.

Any chance for an updated version? Would really appreciate it.

Bjorn
Title: Re: Resample Big Attached Images
Post by: TrueSatan on March 02, 2007, 05:00:35 AM
 The mod is very general purpose as regards SMF versions and just needed an alteration to the package XML...the mod is now tested on 1.1.2 and works properly...assuming all the previous caveats in earlier postings are covered.

I would expect that it would be easy to keep it up to date unless the associated SMF files change drastically and, unless anyone objects, I'll probably post uprated versions as new SMF versions become available...I might do some modifications to the code as well but don't count on that as for my own use it's fine as it is.

If the developer wants me to do so I'll look after this mod...that's up to him though.

The version below adds support for SMF 1.1.1 and 1.1.2
Title: Re: Resample Big Attached Images
Post by: BjornB on March 02, 2007, 05:06:47 AM
I have used this mod for some time, and know about the xml  edit, but it didn't work this time. I'll give it another try using your files.

Bjorn
Title: Re: Resample Big Attached Images
Post by: BjornB on March 02, 2007, 05:19:42 AM
Hi,


This is the error I receive: Fatal error: Call to undefined function: exif_imagetype() in /home/username/public_html/domain/forum/Sources/Post.php on line 1477

Idea what to do?

Thanks de Bjorn
Title: Re: Resample Big Attached Images
Post by: TrueSatan on March 02, 2007, 05:20:38 AM
 Your server probably lacks the necessary support for it or the images aren't compatible with the system...rare but entirely possible. Short of swapping hosting or asking your host to enable the systems you need there's not much that can be done...sorry.

If you want to see what the php setup on your host is then use the file below...upload it to your server then using your browser load the file...it will output onto the browser screen the php configuration details of your hosting.
Title: Re: Resample Big Attached Images
Post by: BjornB on March 02, 2007, 05:32:13 AM
Thanks TrueSatan,

Just found that out. I'm contacting my host to have them '--enable-exif'. Shouldn't be a problem I hope. Everyone else has it  :)
Title: Re: Resample Big Attached Images
Post by: TrueSatan on March 02, 2007, 05:40:07 AM
My pleasure...and good luck...I hope it works out well for you.
Title: Re: Resample Big Attached Images
Post by: BjornB on March 03, 2007, 03:43:30 AM
Host added exif to server and mod is working now.  :D
Title: Re: Resample Big Attached Images
Post by: TrueSatan on March 03, 2007, 03:56:00 AM
Glad to hear it...it's nice to hear somebody say something good once in a while after a few hours dealing with a idiot trying to wreck one of my forums. You put a, much needed, smile back on my face.
Title: Re: Resample Big Attached Images
Post by: Matthew Schenker on March 04, 2007, 11:27:01 AM
This looks like a terrific mod, something I have really been wanting.

Just to be clear, has it been updated to run on 1.1.2?

Thanks!
Title: Re: Resample Big Attached Images
Post by: TrueSatan on March 04, 2007, 11:52:06 AM
Matthew,

As stated above,
Quote
The version below adds support for SMF 1.1.1 and 1.1.2

Use the version in my posting and you should be OK.
Title: Re: Resample Big Attached Images
Post by: Matthew Schenker on March 04, 2007, 12:00:47 PM
TrueSatan,
Thanks for the note!  Sorry if I asked a question that was already answered.  Since I'm still learning, and I'm not a programmer, sometimes I ask for more reassurance.  I'm getting better!

Thank you again.  You are always such a great help.  And it is wonderful the way you put such effort into tweaking modifications to help make them better.  I really appreciate that!!
Title: Re: Resample Big Attached Images
Post by: TrueSatan on March 04, 2007, 12:25:46 PM
 Thanks Matthew,

I hope the mod works out well for you...it was a bit of a pain to tweak for the latest versions but now that it has my updated install file for those versions in the package adding new versions to it as they come along should be easy...just a matter of adding the version number to the compatibility list...unless something gets changed in the SMF core files again.

I found that it clashes with the sticky first post mod and haven't yet got them to work together...that aside it should be fine.
Title: Re: Resample Big Attached Images
Post by: Matthew Schenker on March 04, 2007, 03:52:29 PM
I've installed this in my test forum.  Just want to confirm the purpose of this modification.  It reduces the pixel size, not the KB size.
Title: Re: Resample Big Attached Images
Post by: TrueSatan on March 04, 2007, 04:20:47 PM
 Correct Matthew...by limiting pixel size it stops excessively large images from distorting the layout of your forum.
Title: Re: Resample Big Attached Images
Post by: Matthew Schenker on March 05, 2007, 09:15:16 AM
This is a useful modification.

But does anyone know if there is a modification available that will resize attachments automatically?  I mean, one that reduces the KB size.  This would be really useful.
Title: Re: Resample Big Attached Images
Post by: TrueSatan on March 05, 2007, 11:47:27 AM
 I'm pretty sure that there isn't any such package...
Title: Re: Resample Big Attached Images
Post by: Matthew Schenker on March 05, 2007, 01:14:03 PM
TrueSatan,
You know what my next question is, right?  Can one of you experts develop something like this?

I'm not a programmer, so I apologize if my request is silly.
Title: Re: Resample Big Attached Images
Post by: TrueSatan on March 05, 2007, 03:56:05 PM
Matthew,

I could feel that question coming from afar...but I had fingers, toes and all else that would cross crossed and hoped for the best.

I've had a look through the php EXIF function documentation and that of GD2 and can't see an obvious way to use either to do what you ask. Doubtless it can be done (most things can be done) but I don't know how to do it.

BTW expert...no; bodger...yes!
Title: Re: Resample Big Attached Images
Post by: TRT on April 29, 2007, 08:37:57 PM
This mod killed the ability for me or my users to attach ANY file.

Looks like my host needs to enable exif for me also. I get the above mentioned fatal error when trying to attach any file, image or otherwise.

I uninstalled it, and everything works like it should. I'll reinstall it once I have exif enabled and see if it continues to give me problems.

Using SMF v1.1.2, GD 2.0.28, and no exif listed with phpinfo.
Title: Re: Resample Big Attached Images
Post by: Jaba on September 20, 2007, 09:38:04 AM
Quote from: TrueSatan on March 02, 2007, 05:00:35 AM
The mod is very general purpose as regards SMF versions and just needed an alteration to the package XML...the mod is now tested on 1.1.2 and works properly...assuming all the previous caveats in earlier postings are covered.

I would expect that it would be easy to keep it up to date unless the associated SMF files change drastically and, unless anyone objects, I'll probably post uprated versions as new SMF versions become available...I might do some modifications to the code as well but don't count on that as for my own use it's fine as it is.

If the developer wants me to do so I'll look after this mod...that's up to him though.

The version below adds support for SMF 1.1.1 and 1.1.2
Hi TrueSatan
I'm using 1.1.3 - Server support GD2 and Exif etc!
I edited the package-info.xml and included 1.1.3 and it installed fine.

I got the following error after installing when trying to upload an image in a post, jpg or gif etc!
"An Error Has Occurred!
Your attachment couldn't be saved. This might happen because it took too long to upload or the file is bigger than the server will allow.
Please consult your server administrator for more information."

FYI:
I also noticed that it will not allow retry after failing!
will not allow new attachment to upload and the post post has to be aborted even if the image link is removed!

I've only done very simple edits with PHP but I'm will to have a go if you or someone can point me in the general direction? If it's a simple edit cough...   :P
Title: Re: Resample Big Attached Images
Post by: TrueSatan on September 20, 2007, 11:06:21 AM
 First off a quick update to add support for SMF 1.1.3...file attached (other versions are still supported in the new package.)

Unfortunately your problems isn't an easy, or quick, one to fix...the database on your forum has had the details of the problem image added to it but the actual upload of the image failed...hence the problem. You can't re-upload the image because your forum database thinks it's already there...likewise it won't let the posting continue for the same reason.

You could upload the image via ftp having resized it manually and thus bring database and files back into step (easier than altering the database) and then delete the atachment via the normal ACP methods.

Fortunately this would be a rare occurance but right now I don't see an obvious way out of it...I'll ponder on it at some time when I have more spare time available (though that doesn't happen too often.)
Title: Re: Resample Big Attached Images
Post by: Jaba on September 20, 2007, 03:27:10 PM
Thanx for the reply. I think (I hope) my problem isn't as bad as you think it might be! I don't think it is!

This might just be a problem with my install but this version doesn't work for me either!
When I install this MOD I 100% can not post an image, Gallery is fine as I guess not related as it handles images on its own!

When I remove the MOD once again I can post images! I can post and attach a new image or the image that was failing before, when the MOD was live!
I can also attach the same image that was failing to upload before to the old post that failed image upload when the MOD was live!

I've tried many different image files but the results are always the same!

FYI; My error log:
2: rename(/tmp/phpMsdRWm_resized,/tmp/phpMsdRWm) [<a href='function.rename'>function.rename</a>]: No such file or directory
File: /home/sites/my-web-site/public_html/forum/Sources/Post.php
Line: 1518

2: filesize() [<a href='function.filesize'>function.filesize</a>]: Stat failed for /tmp/phpMsdRWm_resized (errno=2 - No such file or directory)
File: /home/sites/my-web-site/public_html/forum/Sources/Post.php
Line: 1509

2: imagejpeg(): supplied argument is not a valid Image resource
File: /home/sites/my-web-site/public_html/forum/Sources/Post.php
Line: 1506

2: imagecopyresampled(): supplied argument is not a valid Image resource
File: /home/sites/my-web-site/public_html/forum/Sources/Post.php
Line: 1504

2: imagecreatetruecolor() [<a href='function.imagecreatetruecolor'>function.imagecreatetruecolor</a>]: Invalid image dimensions
File: /home/sites/my-web-site/public_html/forum/Sources/Post.php
Line: 1503
------------------------

Anyway, this is not urgent but I would like the MOD to work as it would be good to have more control what is uploaded etc!

Thanx for any info, but like I said it's not urgent.

Title: Re: Resample Big Attached Images
Post by: TrueSatan on September 20, 2007, 08:53:20 PM
Your first two error log entries suggest a misconfiguration of the server by your host...specifically it looks like there is no tmp (temp) directory and thus the mod can't work (I would think that other uses of image resizing would also fail as this mod uses a standard system on the server.)

Unfortunately there's nothing you can do save for asking your host to fix it...once I saw your error log it did make things a lot more clear. My sympathies...
Title: Re: Resample Big Attached Images
Post by: Eva on October 19, 2007, 10:28:02 AM
I downloaded your updated 1.1.3 version but when I tried installing it to SMF1.1.4 I get a file corrupt or not compatible version error...

Have you tested it with SMF1.1.4?
Title: Re: Resample Big Attached Images
Post by: Goad on January 22, 2008, 05:45:20 PM
1.1.4 please!
Title: Re: Resample Big Attached Images
Post by: Rövarn on March 24, 2008, 02:35:44 PM
Quote from: Goad on January 22, 2008, 05:45:20 PM
1.1.4 please!
Test report on 1.1.4: Works great!
:D
Title: Re: Resample Big Attached Images
Post by: Rövarn on March 24, 2008, 02:45:55 PM
Quote from: Matthew Schenker on March 05, 2007, 09:15:16 AM
This is a useful modification.

But does anyone know if there is a modification available that will resize attachments automatically?  I mean, one that reduces the KB size.  This would be really useful.

This one does on my forum!

I upload a .jpg picture 1280 x 960, 778 KB, when uploaded in my forum it is 35.43 KB, 800x600

Very useful, thank you!
Title: Re: Resample Big Attached Images
Post by: denzil69 on April 10, 2008, 10:00:10 AM
i couldnt install this mod using 1.1.4 on default theme.
i changed the code in the zip file (uninstall/install) as instructed in earlier post.

it installed no problem.
but when i use the gallery now and upoload pictures, it has no effect at all and still displays the picture in a size larger than the browser window.

any ideas please?
Title: Re: Resample Big Attached Images
Post by: Macallan on May 06, 2008, 06:10:50 PM
Hi,

wonderful extension, it works fine with version 1.1.5 with new posts (no previous ones).

Great job!
Title: Re: Resample Big Attached Images
Post by: cortez on June 07, 2008, 12:26:14 PM
I am using 1.1.5 and it worked fine for around one week. It's set to 800x800 and now, when I click on thumbnail image is not appearing. But when I click on the name of image, it opens regularly on installed image viewer.

Solutions?

Example link:
http://autobusi.org/index.php?option=com_smf&Itemid=26&topic=1724
Title: Re: Resample Big Attached Images
Post by: cortez on June 27, 2008, 05:11:38 PM
Come on? Can anyone help me?
Title: Re: Resample Big Attached Images
Post by: locau on August 27, 2008, 02:03:22 PM
Quote from: Macallan on May 06, 2008, 06:10:50 PM
Hi,

wonderful extension, it works fine with version 1.1.5 with new posts (no previous ones).

Great job!

Quote from: prljavi_bluzer on June 07, 2008, 12:26:14 PM
I am using 1.1.5 and it worked fine for around one week. It's set to 800x800 and now, when I click on thumbnail image is not appearing. But when I click on the name of image, it opens regularly on installed image viewer.

Solutions?

Example link:
http://autobusi.org/index.php?option=com_smf&Itemid=26&topic=1724

I'm using 1.1.5 and i can't seeem to get this to work, a little help pls ?
What mod have you download? What did you do to make it work ?

For me i get
QuoteThe package you are trying to download or install is either corrupt or not compatible with this version of SMF.
Title: Re: Resample Big Attached Images
Post by: export! on December 06, 2008, 02:42:55 PM
I'm using 1.1.7   I tried the mod - it seemed to install properly but when I tried to upload an attachment I got this error;

Fatal error: Call to undefined function: exif_imagetype() in /[path to sources]/Post.php on line 1481

Looks like Godaddy may not have the supporting packages I need.  ;(
Title: Re: Resample Big Attached Images
Post by: export! on December 18, 2008, 11:06:36 AM
Weird though - now that I dug around a bit isn't exif_imagetype a normal "stock" part of php ??
Title: Re: Resample Big Attached Images
Post by: Spuds on March 16, 2009, 06:17:02 PM
For those that are interested ....

I had a need for this code to help out with large images being uploaded to the site and then causing display format issues etc, etc ... Anyway I did a little refresh to the code that so far is working for me and suits my needs, YMMV

Changes are:
1) support for png and gif, the original code only had jpg support
2) maintains alpha and transparency for png and gifs
3) added quality option in admin panel, this is the amount of compression that is applied to jpg or png files
4) added sharpen function for jpg images, this improves the appearance when they get resized.  Its strength is adaptive so it sharpens based on the amount of resizing done.  This on/off option is available in the admin panel
5) added ability to turn on / off mod from admin panel
6) the options are added under the image width/height in the admin panel

I added basic checks for gd2 in the code so it should not error out if you don't have it installed.  You can check for yourself, look under admin/Support and Credits  ... under support information after server version you should see something like 'GD version: bundled (2.0.34 compatible)'  the key things are bundled and 2.xxx, without that its not going to work.  You also  need exif to determine the type of file.

Think that's it ... since I've only tested it with 1.1.8 that's what the installer will allow.
Title: Re: Resample Big Attached Images
Post by: richard68 on April 07, 2009, 12:50:06 PM
Mod seems to install fine, no errors but in the Admin panel I see the check boxes but no text to the left to know what they are for.  Last time something like this happened it was due to the language files, can you help?
Regards,
Rich
Title: Re: Resample Big Attached Images
Post by: Spuds on April 08, 2009, 10:42:22 AM
Rich,

I can try ... The file that the package currently modifies is $themedir/languages/ModSettings.english.php, this is what should show up next to the check boxes.

If you are not using english, or if your langauge files are not in ModSettings.english.php then the text would not show up.  You need to add the following lines to your language file

$txt['image_quality'] = 'Quality of resized image';
$txt['image_sharpen_onresize'] = 'Sharpen on resize';
$txt['image_resize_onupload'] = 'Enable resize';


Likewise if you want the help pop up for those items you need to find the language help files.  Right now the package modifies $themedir/languages/Help.english.php by adding the following lines

$helptxt['image_quality'] = 'This sets the level of compression for jpg or png files, 100 is no compression, 0 is maximum.  A setting of 75 is recommended';
$helptxt['image_sharpen_onresize'] = 'This will sharpen the resized image (jpg only) to improve the quality but it will also increase the filesize';
$helptxt['image_resize_onupload'] = 'This enables resizing / resampling the image on upload only if either its width / height are above the limits';

Title: Re: Resample Big Attached Images
Post by: cortez on May 16, 2009, 03:35:36 PM
For me it sometimes works, sometimes doesn't work. Why? No erros in forum error log, using 1.1.8 build made by Spuds couple of posts above.

And is there any way to resize already posted images?
Title: Re: Resample Big Attached Images
Post by: ElectricSquid on October 02, 2009, 03:03:57 PM
Quote from: Spuds on March 16, 2009, 06:17:02 PM
For those that are interested ....

I had a need for this code to help out with large images being uploaded to the site and then causing display format issues etc, etc ... Anyway I did a little refresh to the code that so far is working for me and suits my needs, YMMV

Changes are:
1) support for png and gif, the original code only had jpg support
2) maintains alpha and transparency for png and gifs
3) added quality option in admin panel, this is the amount of compression that is applied to jpg or png files
4) added sharpen function for jpg images, this improves the appearance when they get resized.  Its strength is adaptive so it sharpens based on the amount of resizing done.  This on/off option is available in the admin panel
5) added ability to turn on / off mod from admin panel
6) the options are added under the image width/height in the admin panel

I added basic checks for gd2 in the code so it should not error out if you don't have it installed.  You can check for yourself, look under admin/Support and Credits  ... under support information after server version you should see something like 'GD version: bundled (2.0.34 compatible)'  the key things are bundled and 2.xxx, without that its not going to work.  You also  need exif to determine the type of file.

Think that's it ... since I've only tested it with 1.1.8 that's what the installer will allow.

Nice!!

To bad it doesn't load for 1.1.9
Is there a way you can list the file modifications so we can do a manual instal?

I'm trying to get it in there right now.
I figure that I can downgrade from 1.1.9 to 1.1.8
Then install your package
Then upgrade to 1.1.9 again

I'll let you know if it works.



Oh, any upcoming support for SMF 2.0 RC1.2 or above?
This is one of the reasons I was asking for the manual instal file edit data.
I might be able to hack it in there manually.
Title: Re: Resample Big Attached Images
Post by: ElectricSquid on October 02, 2009, 04:21:40 PM
Yup, it worked on 1.1.9
Auto resized a pic that was 1.2M down to 48kb

I had to enable php_exif.dll and php_mbstring.dll, otherwise it gave a white screen after posting (no error in log, just white screen).

After enabling exif and mbstring, everything worked well.

OH, make sure you put enable: php_mbstring.dll before enable php_exif.dll in php.ini, otherwise it will not work. (it's not that way by default in php 5.2.6)
Mbstring needs to load before exif. Something about exif needs mbstring to already be loaded because exif depends on mbstring to load.
Title: Re: Resample Big Attached Images
Post by: Oliver.Z on January 23, 2010, 08:53:00 AM
Hello,
I installed it on 1.1.11 and now I have the "White Screen Problem"
Can someone explain to me how I install the mbstring and exif on
Linux 2.6.18-028stab064.7 with PHP 5.2.9 ?

Thx Olli

Title: Re: Resample Big Attached Images
Post by: Oliver.Z on February 01, 2010, 12:57:19 PM
Hello, I'm again
OK, mbstring and exif is installed and work's fine
Now I have an error when i post a picture
Look at that

Quote
1. imagecreatetruecolor(): Invalid image dimensions
Datei: /srv/www/vhosts/***/httpdocs/smf/Sources/Post.php
Zeile: 1582

2. imagecopyresampled(): supplied argument is not a valid Image resource
Datei: /srv/www/vhosts/***/httpdocs/smf/Sources/Post.php
Zeile: 1597

3. imageconvolution() expects parameter 1 to be resource, boolean given
Datei: /srv/www/vhosts/***/httpdocs/smf/Sources/Post.php
Zeile: 1618

4. imagejpeg(): supplied argument is not a valid Image resource
Datei: /srv/www/vhosts/***/httpdocs/smf/Sources/Post.php
Zeile: 1634

5. filesize(): SAFE MODE Restriction in effect. The script whose uid is 10001 is not allowed to access /tmp owned by uid 0
Datei: /srv/www/vhosts/***/httpdocs/smf/Sources/Post.php
Zeile: 1649

6. filesize(): stat failed for /tmp/phpX0Lghx_resized
Datei: /srv/www/vhosts/***/httpdocs/smf/Sources/Post.php
Zeile: 1649

7. rename(): SAFE MODE Restriction in effect. The script whose uid is 10001 is not allowed to access /tmp owned by uid 0
Datei: /srv/www/vhosts/***/httpdocs/smf/Sources/Post.php
Zeile: 1654

8. move_uploaded_file(/tmp/phpX0Lghx): failed to open stream: No such file or directory
Datei: /srv/www/vhosts/***/httpdocs/smf/Sources/Subs-Post.php
Zeile: 1791

9. move_uploaded_file(): Unable to move '/tmp/phpX0Lghx' to '/srv/www/vhosts/***/httpdocs/smf/attachments/23184....
Datei: /srv/www/vhosts/***/httpdocs/smf/Sources/Subs-Post.php
Zeile: 1791

10.Failed to save the file, please try again