ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Distribution: debian, gentoo, os x (darwin), ubuntu
i think you might have an endless loop there!
because you are always working with
$im = imagecreatefromstring ($fileContent);
and $fileContent does not seem to schange!!
starting off with a size of 512KB+ (anything above 512KB) you runn into the look that continues until the size is smaller than 256KB,
you half filesize but will end with more than 256KB (because you are starting with mor than 512KB) and you need to run the loop again, resetting $im to what it was in the first round!!
(if i got that right that is :-P )
it seems the file size isn't going down when I rewrite the file based upon a lower quality. Going back to what Nathanael said, It may be the $fileContent that's causing this problem. I'm stumped for solutions except making the file originally at 100% quality, assigning that a temporary filename, then making all of the new files based upon the previous just-made file. Then, once two files are existant, deleting the first, hopefully larger, file.
Does that sound like it would work? Does anyone have any ideas other than this?!?
If either side of the && expression is false, the entire expression is false, which exits the loop. So if the size is too large but qual has sunk to -10, the loop exits regardless. If the size goes below the threshold before qual reaches zero, it still quits, because the && expression evaluates false. Remember that the while loop runs only as long as the expression is true.
With your || expression, the condition is not false until BOTH halves are false, so the size could be lower than the threshold, but it will continue through the loop until qual reaches -10 (effectively making each picture the very worst quality).