Forum Moderators: coopster
Due to limitations of the shared hosting, I had to use the imagecreate() function.
When I create thumbnails from original files between 55 and 60 kb, with jpg_qual set at 75, the thumbnails on my local server have a size ranging between 6 and 8 kb, with nice colors, and with the very same script on the real server, the thumbnail size stays always significantly below 3 kb, and look like pieces of garbage, sloppy colors, and are almost unreckognizable.
It must have something to do with the shared server, but my question is: what should I look at or for, to understand this drastic loss of quality in real conditions.
Knowing that the truecolor equivalent of the imagecreate() is not available, is there a workaround to maintain a decent thumbnail quality?
If it matters, the hosting is a V50 plan at Ventures Online (that was their old name, now it is data + something, cann't remember it).
Thanx
Notawiz
Also, do you know whether your host has or will install either of the following
- ImageMagick
- NetPBM
I find that ImageMagick generates better thumbs (even with GD2 truecolor) and it *seems* faster (not benchmarked) than the GD library. These are not PHP libraries, so you'll need to be able to make exec() calls. furthermore, it's also a fair bit easier to code - one line of code resizes and preserves aspect ratio automatically.
I haven't used NetPBM, but I've heard it's similar to ImageMagick.
I guess that doesn't really answer your question, but it might be something to check out.
Thanx for the swift replies.
I checked the phpinfo, but forgot to mention my findings.
The GD version says: bundled (2.0.28 compatible).
As for ImageMagic and NetPBM, the answer is NO (according to the host's forum).
But I've noticed for many other things that this shared hosting plan comes with a lot of limited or disabled functions.
Since I'm only the developer and not the owner of the site, there is not much I can do about that, than try to find workarounds. With your help, of course.
Notawiz.
I installed phpThumb like suggested, and did not get better results. On my local development server, they even are worse.
As said earlier, starting from exactly the same source 60 Kb jpg files, and with the same script, the thumbs (qual 75) generated on my local development server have a size up to 8 Kb, there where those on the remote production (shared) server never exceed 3 Kb.
So we focussed on the version of GD. Local: GD 1.6.2
Remote: GD 2.0.28.
The remote should produce the best quality thumbs, but it is just the contrary.
While comparing the installations with phpinfo(), I noticed this morning that on the shared host they did not install EXIF.
Could it be that this, combined with disabling the truecolor function, leads to that very bad image quality on the production server? And this significant difference in size (ratio 1 to 4)?
Notawiz
Personally, for thumbnail quality, I just prefer ImageMagick as mentioned above. Do you have shell access? If so, log in and type
>mogrify
if it says anything other than "command not found" or equivalent, you have ImageMagick. Do the same for
>convert
If you don't find it, all is not lost. Do a unix find for convert or mogrify.
find / -name "mogrify*" 2>/dev/null
Notes:
/ - that says to start at system root.
2>/dev/null - throw away error output. You'll get pages of it with a search starting at root, since you don't have permission on lots of dirs.
If you still don't find it, ask your sysadmin if it's somewhere available (e.g. one of the protected dirs) with a method of access for users (i.e. get the path).
The client only gave me an ftp access code.
And when I asked about "shell", she was as puzzled as I am.
I understand what it means, but that's about it, and my client will not be of much help since she already has problems with a mouse (you know, people fixing their mouse when moving it, instead of looking at the pointer on the screen, well, she is that type. Makes me some kind of a genius compared to her...).
Just to make sure, I consulted the old data sheet of her hosting plan, and it only talks about "management of your site through CPanel", so I guess that means that there is not such a thing as an access to shell commands.
But even if ImageMagick is better according to your experience, that still does not explain why the same script with the same originals give such a big difference, especially since the best quality is generated by the oldest GD install?
As for EXIF, I read somewhere that one of it's functions consist of extracting the thumbnail when it has been embedded in jpg files. This could explain why my local installation (with EXIF) has nice looking thumbs and the server (without EXIF) has such lousy ones, don't you think?
Still open to new suggestions.
Have a nice WE.
Notawiz
As for EXIF, I read somewhere that one of it's functions consist of extracting the thumbnail when it has been embedded in jpg files.
This is an either/or not a better/worse thing. Either you are extracting the thumbnail using exif_thumnail() or you're not, and either it works if the function is available or it doesn't.
If you're using the GD library to resize an image, it is never using the exif thumnail info.
[edit]I see the following was answered in your first post. Too bad[/edit]
A thought and important question
Are you setting the jpeg quality of your image or letting it use the system defaults? GD defaults to a quality of 75 if I remember correctly. I wonder if the live server has some master setting that reduces that. In other words, in your imagejpeg() command, try explicitly setting a quality
imagejpeg ($img_resource, $save_file, 95);
That might do it for you
As for shell access, that means access to a window that looks like your DOS command prompt. Generally if you have FTP access, you have shell access with similar requirements (secure or non-secure login). I use SSH Secure Shell and I think it's free, but I don't remember. Login parameters (host, username, password) should be the same as for FTP.