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 9015485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:45:44+00:00 2026-06-16T03:45:44+00:00

I have an external PHP file that does some image resizing (image.php). I need

  • 0

I have an external PHP file that does some image resizing (image.php). I need to call it every time a ‘image’ tag is used so it can fill in the “src”. How would I tell the HTML file to use the external PHP page and how would I make it use it when processing the ‘image’ “src” tag?

This is what im using to try to display the image.

Do i need to include something in my ‘head’ section?

thanks for the help!

<li><a href= "/intPics//1.jpg"> <img src="<?php loadImage('/intPics//1.jpg', 300,300) ?>"<div>1.jpg</div></a></li>

This is the PHP file

<?php



   function imageResizer($url, $width, $height) {



                header('Content-type: image/jpeg');



                list($width_orig, $height_orig) = getimagesize($url);



                $ratio_orig = $width_orig/$height_orig;



                if ($width/$height > $ratio_orig) {

                  $width = $height*$ratio_orig;

                } else {

                  $height = $width/$ratio_orig;

                }



                // This resamples the image

                $image_p = imagecreatetruecolor($width, $height);

                $image = imagecreatefromjpeg($url);

                imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height,     $width_orig, $height_orig);



                // Output the image

                imagejpeg($image_p, null, 100);



        }



        /    /works with both POST and GET

        $method = $_SERVER['REQUEST_METHOD'];



        if ($method == 'GET') {



                imageResize($_GET['url'], $_GET['w'], $_GET['h']);



         } elseif ($method == 'POST') {



            imageResize($_POST['url'], $_POST['w'], $_POST['h']);

         }



      // makes the process simpler

        function loadImage($url, $width, $height){

         echo 'image.php?url=', urlencode($url) ,

         '&w=',$width,

         '&h=',$height;

        }



?>
  • 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-16T03:45:45+00:00Added an answer on June 16, 2026 at 3:45 am

    I don’t know if I understood your question correctly but I’ll try to answer:

    You could call the php script directly from the src in your image tag

    <img src="image.php" />
    

    and in your php file you would set the content-type to an image format

    <?php header('Content-Type:image/jpeg'); ?>
    

    This way the php script returns an image. You could even pass paramters, e.g. image.php?width=200&height=100 to the php script.

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

Sidebar

Related Questions

I have a index.php file that will include several external files: content/templates/id1/template.php content/templates/id2/template.php content/templates/id3/template.php
I have an external file with some vars to require in my php class
I have a div that is populated with an external php file, that loops
I have a page (main.php) which loads content from an external PHP file (rpc.php).
I have an external file in php, outputed as json format I want the
I have a PHP page that loads external content using other PHP files. I'm
I have certain PHP class methods that access external variables. These variables are not
I have a PHP script that grabs data from an external service and saves
I have external html5 canvas that you can paint on some lines using your
I have a external js file handling deleting some element. According to the result,

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.