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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:05:05+00:00 2026-06-09T13:05:05+00:00

So I am trying to write a little script to crop a users image.

  • 0

So I am trying to write a little script to crop a users image. I would send some information (width, height, alignment properties and image url) to the script and it should return the image cropped. However, it’s not working… Just an “image not found” symbol :/ Here is my script, any thoughts?

<?php
session_start();
header('Content-type: image/jpeg');
$w=$_GET['w'];
$h=$_GET['h'];
$x=$_GET['x'];
$y=$_GET['y'];
$filename="http://www.domain.com/".$_GET['src'];
$file_ext = substr($filename, strrpos($filename, ".") + 1);
$ext='';

if($file_ext=='jpg')
{
    $image = imagecreatefromjpeg($filename); 
}
else if ($file_ext=='gif')
{
    $image = imagecreatefromgif($filename); 
}
else if ($file_ext=='png')
{
    $image = imagecreatefrompng($filename); 
} 

$crop = imagecreatetruecolor($w,$h);
imagecopy($crop, $image, 0, 0, $x, $y, $w, $h);
imagejpeg($crop);
?>

Edit: Looks like this is the error: Fatal error: Call to undefined function imagecreatetruecolor() in domainpath/crop.php on line 24 Is there anything I need to do to load this function?

  • 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-09T13:05:06+00:00Added an answer on June 9, 2026 at 1:05 pm

    Using ImageMagick, try this;

    <?php
    function resize_image($file, $w, $h, $crop=FALSE) {
        $img = new Imagick($file);
        if ($crop) {
            $img->cropThumbnailImage($w, $h);
        } else {
            $img->thumbnailImage($w, $h, TRUE);
        }
    
        return $img;
    }
    resize_image(‘/path/to/some/image.jpg’, 150, 150);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a little Emacs Lisp script that reads a csv file
I'm just learning jQuery, and I'm trying to write a little script. To sum
I am currently trying to write a little powershell script (I have no experience
I am trying to write a little script myself to compute all of the
I'm trying to write a little greasemonkey script/bookmarklet/what have you for Google Docs. The
I'm trying to write a little script to clean my directories. In fact I
I'm trying to write a bash script and I needed to do some floating
I'm trying to write a Greasemonkey script, and would like to use the jQuery
I'm trying to write a script that stores some data chunks inside flat .txt
i´m trying to write a little script for writting a sqlite table from an

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.