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

  • Home
  • SEARCH
  • 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 8099895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:33:39+00:00 2026-06-05T22:33:39+00:00

I’m currently trying to teach myself PHP by doing a small image-processing type project

  • 0

I’m currently trying to teach myself PHP by doing a small image-processing type project with Imagemagick. To start off with the basics, I wrote some simple code to read in an image and convert it to a PNG.

However, while I’m able to read from local image files, I am completely unable to read in images from URLs, as it crashes when I call readImageFile() on the url, and I get the following error:

Fatal error: Uncaught exception ‘ImagickException’ with message ‘Invalid CRT parameters detected’ in C:\xampp\htdocs\imagepractice\imagemagicktest.php:8 Stack trace: #0 C:\xampp\htdocs\imagepractice\imagemagicktest.php(8): Imagick->readimagefile(Resource id #3) #1 {main} thrown in C:\xampp\htdocs\imagepractice\imagemagicktest.php on line 8

I’ve spent the last hour Googling for a way to fix this, to no avail, and the only lead I have been able to find is Error in using readImage function (Imagick). However, unlike that issue, I am perfectly able to use readImage, and I’m even able to use readImageFile on local files, just not on image URLs.

From the only comment there, it seems that it may possibly be a bug specific to Windows, but I was wondering if anyone happens to be able to confirm/deny this and/or suggest a way to fix the CRT parameter error?

For reference, the code I wrote is below:

<?php
$im = new Imagick();

//$im->newPseudoImage(1000, 1000, "magick:rose"); //this works!

//$im->readImage("images\\wheels.jpg"); // this works!

$handle = fopen("http://www.google.com/images/srpr/logo3w.png", "rb");
$im->readImageFile($handle); //this line crashes!
fclose($handle);

$im->setImageFormat("png");
$type = $im->getFormat();
header("Content-type: $type");
echo $im->getImageBlob();
?>

In addition, I am running 64-bit Windows 7, and I am using XAMPP 1.7.7 (which uses PHP 5.3.8), and I initially installed Imagemagick 6.6.4 using these instructions. (Although I replaced the 6.6.4 version with Imagemagick 6.6.2 instead, as per the suggestion of a commenter here, which hasn’t fixed anything.)

  • 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-05T22:33:41+00:00Added an answer on June 5, 2026 at 10:33 pm

    Thanks to some friendly folks at another coding forum, I finally figured out how to stop the getting the error and make this code work. Unfortunately, I’m still not sure what was causing the CRT Parameter error in the first place, but switching from fopen to file_get_contents solved the issue for me.

    Working updated code:

    <?php
    ini_set('display_errors', 'On');
    error_reporting(E_ALL | E_STRICT);
    
    $im = new Imagick();
    
    //$im->newPseudoImage(1000, 1000, "magick:rose"); //this works!
    //$im->readImage("images\\wheels.jpg"); //this works!
    
    $url = "http://www.google.com/images/srpr/logo3w.png";
    $source = @file_get_contents($url);
    if(!$source){
        throw new Exception("failed to retrieve contents of $url");
    }
    
    $im->readImageBlob($source);
    
    $im->setImageFormat("png");
    $type = $im->getFormat();
    header("Content-type: $type");
    echo $im->getImageBlob();
    ?>
    

    However, according to someone else at the forum I posted this on,

    Use curl, some places have allow_url_fopen disabled in PHP. I do some development on my Windows 7 64-bit machine using XAMPP and curl works everytime no matter what I am doing.

    so just to be safe, I’ll probably change to using curl instead and seeing if that works, but at least I’ve solved my issue for now!

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
Specifically, suppose I start with the string string =hello \'i am \' me And

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.