SunQuest
 
           PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old June 8th, 2004, 07:12 PM
chewiee chewiee is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 1 chewiee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool GD Jpeg Resize looks like 4bit image from IIS

Hi guys, why is it the first post I always do is a question and not an answer??!

OK I have some code that I was given by a developer that used to work with me that resized a .jpg once uploaded to a website.

The thing is it works fine on my Raq4, the image is a nice resolution and is totally presentable to visitors. I use IIS (shhh don't tell anyone) as a development server and the same code is producing some really bad looking images.

Enclosed is the 'offending' code... I think, as the rest that the form does is some db entries, and of course the image upload, which works fine as the original image that is uploaded is fully ok.

Please advise...

PHP Code:
function resize_jpeg$image_file_path$new_image_file_path$max_width=480$max_height=1600 )
{
/*
* resize_jpeg takes in a local image and outputs a resized copy.
* you send the full unix path, including filename, to the local
* image (a relative path will work, too),
* the full path to the new, smaller image, and the maximum width
* and height you'd like the image to be constrained within.
* the script will not distort the image at all, except for the
* standard degradation of the image through resizing.
* returns TRUE or FALSE
*
* ex: resize_jpeg ( "/home/allah/images/blah.jpg", "/home/allah/images/small_blah.jpg", 300 );
* ex: resize_jpeg ( "../images/yikes.jpg", "../images/800x800_yikes.jpg", 800, 800 );
*/

    
$return_val 1;
    
$return_val = ( ($img ImageCreateFromJPEG $image_file_path )) && $return_val == ) ? "1" "0";
    
$FullImage_width imagesx ($img);    // Original image width
    
$FullImage_height imagesy ($img);    // Original image height
    // now we check for over-sized images and pare them down
    // to the dimensions we need for display purposes
    
$ratio =  ( $FullImage_width $max_width ) ? (real)($max_width $FullImage_width) : ;
    
$new_width = ((int)($FullImage_width $ratio));      //full-size width
    
$new_height = ((int)($FullImage_height $ratio));    //full-size height
    //check for images that are still too high
    
$ratio =  ( $new_height $max_height ) ? (real)($max_height $new_height) : ;
    
$new_width = ((int)($new_width $ratio));    //mid-size width
    
$new_height = ((int)($new_height $ratio));    //mid-size height

    // --Start Full Creation, Copying--
    // now, before we get silly and 'resize' an image that doesn't need it...
    
if ( $new_width == $FullImage_width && $new_height == $FullImage_height )
        
copy $image_file_path$new_image_file_path );
    
$full_id ImageCreate$new_width $new_height );        //create an image
    
ImageCopyResized$full_id$img,
                    
0,0,  0,0//starting points
                    
$new_width$new_height,
                    
$FullImage_width$FullImage_height );
    
$return_val = ( $full ImageJPEG$full_id$new_image_file_path80 )
                 && 
$return_val == ) ? "1" "0";
    
ImageDestroy$full_id );
            
// --End Creation, Copying--
    
return ($return_val) ? TRUE FALSE ;


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > GD Jpeg Resize looks like 4bit image from IIS


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway