Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8523969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:33:34+00:00 2026-06-11T07:33:34+00:00

Once again, here I am with a simple issue that I cannot solve because

  • 0

Once again, here I am with a simple issue that I cannot solve because the search terms I use apparently don’t match the ones that have been used before. What I want to create is just a tiny piece of script making it possible to change the image width using the URL.

An example can be found on http://waarneming.nl/fotonew/0/2639780.jpg. If you add the variables ?w=100&h=100, the image is resized. Important to mention is that I need no cropping (which doesn’t happen in the example too, even though 100×100 is of course not the right ratio). The only thing to happen is what can be done with CSS and HTML too: change height and width of a larger picture. But because I need the resized image in another script, I want to use URL variables.

Hope you can help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:33:36+00:00Added an answer on June 11, 2026 at 7:33 am

    Use the SimpleImage library:

    <?php
    
    /*
    * File: SimpleImage.php
    * Author: Simon Jarvis
    * Copyright: 2006 Simon Jarvis
    * Date: 08/11/06
    * Link: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
    *
    * This program is free software; you can redistribute it and/or
    * modify it under the terms of the GNU General Public License
    * as published by the Free Software Foundation; either version 2
    * of the License, or (at your option) any later version.
    *
    * This program is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    * GNU General Public License for more details:
    * http://www.gnu.org/licenses/gpl.html
    *
    */
    
    class SimpleImage {
    
       var $image;
       var $image_type;
    
       function load($filename) {
    
          $image_info = getimagesize($filename);
          $this->image_type = $image_info[2];
          if( $this->image_type == IMAGETYPE_JPEG ) {
    
             $this->image = imagecreatefromjpeg($filename);
          } elseif( $this->image_type == IMAGETYPE_GIF ) {
    
             $this->image = imagecreatefromgif($filename);
          } elseif( $this->image_type == IMAGETYPE_PNG ) {
    
             $this->image = imagecreatefrompng($filename);
          }
       }
       function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) {
    
          if( $image_type == IMAGETYPE_JPEG ) {
             imagejpeg($this->image,$filename,$compression);
          } elseif( $image_type == IMAGETYPE_GIF ) {
    
             imagegif($this->image,$filename);
          } elseif( $image_type == IMAGETYPE_PNG ) {
    
             imagepng($this->image,$filename);
          }
          if( $permissions != null) {
    
             chmod($filename,$permissions);
          }
       }
       function output($image_type=IMAGETYPE_JPEG) {
    
          if( $image_type == IMAGETYPE_JPEG ) {
             imagejpeg($this->image);
          } elseif( $image_type == IMAGETYPE_GIF ) {
    
             imagegif($this->image);
          } elseif( $image_type == IMAGETYPE_PNG ) {
    
             imagepng($this->image);
          }
       }
       function getWidth() {
    
          return imagesx($this->image);
       }
       function getHeight() {
    
          return imagesy($this->image);
       }
       function resizeToHeight($height) {
    
          $ratio = $height / $this->getHeight();
          $width = $this->getWidth() * $ratio;
          $this->resize($width,$height);
       }
    
       function resizeToWidth($width) {
          $ratio = $width / $this->getWidth();
          $height = $this->getheight() * $ratio;
          $this->resize($width,$height);
       }
    
       function scale($scale) {
          $width = $this->getWidth() * $scale/100;
          $height = $this->getheight() * $scale/100;
          $this->resize($width,$height);
       }
    
       function resize($width,$height) {
          $new_image = imagecreatetruecolor($width, $height);
          imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
          $this->image = $new_image;
       }      
    
    }
    ?>
    

    Then, try this:

    <?php
       include('SimpleImage.php');
       $image = new SimpleImage();
       $image->load($_GET['file']);
       $image->resize($_GET['width'], $_GET['height']);
       $image->output();
    ?>
    

    In order to call the script, you would pass the filename, width and height through your URL. Assuming the script is named foo.php:

    http://www.example.com/foo.php?file=picture_name.jpg&width=100&height=100

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Once again I find myself failing at some really simple task in C++. Sometimes
Once again I was in a design review, and encountered the claim that the
I'm running into a very strange issue here with wrong object state that I
Simple problem, though apparently not a simple solution. Example here: http://myhideout.eu/new/ Basically the site
once again conversion problem in Delphi. I've been through some other topics, that refer
Once again I can't find a neat solution for a simple UI problem in
Pulling my hair out with AJAX once again. This is a simple list plugin
Once again, I'm at a loss with IE7 on this one. I'm making a
Once again I'm receiving structs via UDP from a C++ programm, Now I ported
Once again, lists are boggling my mind. <div id=headbottom> <ul id=headnavbutton> <li id=button1 class=headnavbutton></li>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.