Dinocanid |
09-03-2017 09:37 PM |
Unable to read file? (Imagick issue)
I heard that Mysidiahost allowed Imagick, so I decided to upload my site so I could work on online features. The only problem is that I get a nasty "failed to read file" error when I try. I also get this:
Quote:
trict Standards: Only variables should be passed by reference in /home/wildsoul/public_html/wolfimage.php on line 10
|
I usually don't worry about strict standards and make them invisible, but doing that this time doesn't solve anything. This is the code in question:
PHP Code:
<?php
class WolfimageController extends AppController{
//error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);
public function index(){
// Lets setup the database.
$mysidia = Registry::get("mysidia");
//A not-so-clean way to get the wid of the parent page
$fullurl = $_SERVER['HTTP_REFERER'];
$cleanwid = end(explode('/',trim($fullurl,'/')));
$pet = $mysidia->db->select("wolves", array(), "wid='$cleanwid'")->fetchObject();
// Remember to order these in reverse, the last element in the array should always be the top layer you will see (usually lineart). All images should be the same dimensions. The first element in the array is [0], not [1]!!!!
$images = array(
'http://wild-souls.mysidiahost.com/picuploads/den.png',
"http://wild-souls.mysidiahost.com/picuploads/wolf_images/pup/bases/" . $pet->base . " base-pup.png",
'http://wild-souls.mysidiahost.com/picuploads/wolf_images/pup/markings/' . $pet->marking1 . '-pup.png',
'http://wild-souls.mysidiahost.com/picuploads/wolf_images/pup/eyes/eyes ' . $pet->eyes . '-pup.png',
'http://wild-souls.mysidiahost.com/picuploads/wolf_images/pup/shade-pup.png',
'http://wild-souls.mysidiahost.com/picuploads/wolf_images/pup/lineart-pup.png'
);
// This creates the Imagick class that we will use.
$composed_image = new \Imagick($images);
// Base
$composed_image->setIteratorIndex(2);
$composed_image->compositeImage( new \Imagick($images[1]), \Imagick::COMPOSITE_DSTIN, 0, 0 );
$composed_image->setIteratorIndex(4);
$composed_image->compositeImage( new \Imagick($images[1]), \Imagick::COMPOSITE_DSTIN, 0, 0 );
// As you see above, by calling setIteratorIndex(), you switch your "working layer" to the layer you wish to modify.
// Now lets flatten it and display it. This creates a new Imagick instance to work with with only one flat image.
$image = $composed_image->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN);
$image->setImageFormat('png');
header('Content-type: image/png');
echo $image->getImageBlob();
}
}
?>
I have to use the full URL since the Imagick version seems to have issues with relative paths. I had to install the plugin myself during local testing, so I'm not sure if mysidiahost calls imagick differently.
|