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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:20:26+00:00 2026-05-20T18:20:26+00:00

The following PHP, when passed this image , writes 0 bytes to $cache (but

  • 0

The following PHP, when passed this image, writes 0 bytes to $cache (but works fine with all other known images). If the echo just before the call to writeImage is uncommented, it works fine. (The PHP is being run via <?php exec('php -f thumb.php -- img=zc9vfo.png >output'); ?> for unrelated reasons.) If anyone can give me a hint for what to look into, that would be fantastic.

if(isset($argc) && (!isset($_GET) || empty($_GET))){
  for($i = 1; $i < $argc; ++$i){
    if(strpos($argv[$i], '--') === 0){
      $argv[$i] = substr($argv[$i], 2);
    }
    list($key, $value) = explode('=', $argv[$i], 2);
    $_GET[$key] = $value;
  }
}

if(!isset($_SERVER['DOCUMENT_ROOT']) || $_SERVER['DOCUMENT_ROOT'] == ''){
  $_SERVER['DOCUMENT_ROOT'] = /* ... */;
}

$name =& $_GET['img'];
if(!isset($name)){
  die('unspecified');
}

$pipe_name = realpath("{$_SERVER['DOCUMENT_ROOT']}/lib/php/pipes") . "/$name";
if(!file_exists($pipe_name) && !posix_mkfifo($pipe_name, 0777)){
  file_put_contents('output', 'Pipe could not be created.');
  exit(1);
}
$pipe = fopen($pipe_name, 'r+');
if(!$pipe){
  file_put_contents('output', 'Pipe could not be opened.');
  exit(1);
}

function pipe($msg, $die=FALSE){
  global $pipe;
  fwrite($pipe, $msg . PHP_EOL);
  if($die){
    die($msg);
  }else{
    echo $msg;
  }
}

$w = 150;
$h = 114;

if(!file_exists($image = $_SERVER['DOCUMENT_ROOT'] . '/images/' . $name)){
  pipe('invalid', TRUE);
}
$cache = $_SERVER['DOCUMENT_ROOT'] . '/thumbs/' . $name;
if(!file_exists($cache)){
  $thumb = new Imagick($image);
  $thumb->flattenImages();
  $quotient = min($thumb->getImageWidth() / $w,
                  $thumb->getImageHeight() / $h);
  $thumb->cropImage($w * $quotient, $h * $quotient, 0, 0);
  $thumb->scaleImage($w, $h);
//  echo $thumb->getImageBlob();
  $thumb->writeImage($cache);
}

pipe('success');

fclose($pipe);

?>
  • 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-05-20T18:20:27+00:00Added an answer on May 20, 2026 at 6:20 pm

    I apparently have a faulty installation of ImageMagick, IMagick, and/or libpng. See this forum thread:
    http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=18326

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

Sidebar

Related Questions

I have the following PHP code which works out the possible combinations from a
I have following PHP code $val=<div id=user.$row['cid']. userid=.$row['cid']. class=innertxt><img src=images/images.jpg width=50 height=50><strong>.$uname.</strong><ul> <li>Email: .$row['cemail'].</li>
I have the following PHP script: <?php $fortune = `fortune`; echo $fortune; ?> but
I've tested the following and it works on both PHP 5.2 and 5.3, however,
I have the following php object(??? new to this). It is being sent through
I have the following line of PHP code which works great: exec( 'wget http://www.mydomain.com/u1.php
How does php access a variable passed by JQuery? I have the following code:
The following is passed to the browser: http://localhost/like.php?f=1 where f=1 is the article ID
The following PHP code snippet uses GD to resize a browser-uploaded PNG to 128x128.
I am running following PHP code to interact with a MS Access database. $odbc_con

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.