Comments (4)
I have tried another code as showed in the tutorial and it saves the image edited in a folder, that works beautiful. But what I am getting is a blank thumbnail. I would like that the image is displayed on the web browser to let the user view the image before save. this is my code.
getWidth(); echo''; echo $pinguLayer->getHeight(); echo'
'; echo $pinguLayer->getWidth(); echo'
'; echo $pinguLayer->getHeight(); echo'
'; $wwfLogoLayer = ImageWorkshop::initFromPath('images/Google-icon.jpg'); $tuxLayer = ImageWorkshop::initFromPath('images/Mylogolow.gif'); $tuxLayer->resizeInPixel(100, null, true); // resize pingu layer $pinguLayer->resizeInPixel(400, null, true); // Add 2 layers on pingu layer $pinguLayer->addLayerOnTop($wwfLogoLayer, 20, 10, 'LB');//LB== Left bottom $pinguLayer->addLayerOnTop($tuxLayer, 20, 10, 'RT');//RT = Right Top // Saving the result $dirPath =" ImageworkshopUploads"; $filename = "pingu_edited.png"; $createFolders = true; $backgroundColor = null; // transparent, only for PNG (otherwise it will be white if set null) $imageQuality = 95; // useless for GIF, usefull for PNG and JPEG (0 to 100%) $pinguLayer->save($dirPath, $filename, $createFolders, $backgroundColor, $imageQuality); $image = $pinguLayer->getResult(); //header('Content-Length: '.filesize($image)); header("Content-type: image/jpeg"); //print file_get_contents($image); imagejpeg($image, null, 95); // We chose to show a JPG with a quality of 95% ?>
from imageworkshop.
I found what was wrong. I removed
echo $pinguLayer->getWidth();
echo'';
echo $pinguLayer->getHeight();
echo'';
echo $pinguLayer->getWidth();
echo'';
echo $pinguLayer->getHeight();
echo'';
and now it works
from imageworkshop.
ini_set('display_errors', 'On');error_reporting(E_ALL);
require_once(DIR.'/PHPImageWorkshop/ImageWorkshop.php');
use PHPImageWorkshop\ImageWorkshop;
//var_dump(file_exists('PHPImageWorkshop/banner1.jpg'));// breaks the
header output log it elsewhere using a file logger
//var_dump(class_exists('PHPImageWorkshop\ImageWorkshop'));// breaks the
header output log it elsewhere using a file logger
$layer=ImageWorkshop::initFromPath('PHPImageWorkshop/banner1.jpg');
//var_dump(get_class($layer)); // breaks the header output log it elsewhere
using a file logger
//echo $layer->getWidth();// breaks the header output log it elsewhere
using a file logger
//echo $layer->getHeight();// breaks the header output log it elsewhere
using a file logger
$layer->resizeInPixel(400, null, true);
$image = $layer->getResult();
header('Content-type: image/jpeg');
imagejpeg($image, null, 95); // We chose to show a JPG with a quality of 95%
you can't have echos or var_dump in a picture file it don't work you could
try throwing exceptions on errors so you would know if something fail by
visual output when it is rendered in a broswer but that would be the only
way, or have to scripts files on test file the other the production file
On Tue, Apr 8, 2014 at 12:59 PM, chrbono [email protected] wrote:
I found what was wrong. I removed
echo $pinguLayer->getWidth();
echo'';
echo $pinguLayer->getHeight();
echo'';echo $pinguLayer->getWidth();
echo'';
echo $pinguLayer->getHeight();
echo'';and now it works
Reply to this email directly or view it on GitHubhttps://github.com//issues/38#issuecomment-39887754
.
from imageworkshop.
//Test.php:
getWidth(); echo $layer->getHeight(); ?>//Production_file.php:
resizeInPixel(400, null, true); $image = $layer->getResult(); if(!isset($Test)){// if this file is loaded by test.php then $test will be set. header('Content-type: image/jpeg'); imagejpeg($image, null, 95); // We chose to show a JPG with a quality of 95% } Just to note the best way to do this is to make 2 classes on the logic and one the test and then us methods etc to test the system. please read up on Test Driven Developmentfrom imageworkshop.
Related Issues (20)
- Move documentation to github repo HOT 4
- Fatal error: Uncaught Error: Class 'PHPImageWorkshop\Core\ImageWorkshopLayer' HOT 11
- Issue release in packageist HOT 1
- Right align text HOT 1
- Documentation Issues
- How to write Multi Line text
- GifCreator doesn't work
- White or Black bars with PNG and transparent background
- Webp support HOT 4
- Opening an optimized PNG (256 colors) result a grey block HOT 1
- Is it possible to wrap text to certain width ??
- GifCreator and global color palette?
- resizeToCover, like in css?
- PHP8 uses GDImage object instead resource HOT 4
- PHP Fatal error: Uncaught Error: Class "packages\PHPImageWorkshop\ImageWorkshop" not found HOT 1
- Problems with php 8.1 HOT 3
- Fix in convertHexToRGB method HOT 2
- Php Image Workshop supporting 8.1.13 or not HOT 1
- PHP deprecated function convertHexToRGB at php 8.1 HOT 7
- Working with grayscale png images
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imageworkshop.