Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Make a solid black image

Posted on 2011-09-10
1
Medium Priority
?
242 Views
Last Modified: 2012-05-12
In this question:

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_27291199.html#a36515211

Everything is working great with the solution, but the black image involved is still a manual task, so I have a new question:

Given a random image, called image.jpg, how would you read the width and height and create  a solid black image of the same width and height and save it as image_black.jpg
0
Comment
Question by:hrolsons
1 Comment
 
LVL 10

Accepted Solution

by:
Derokorian earned 2000 total points
ID: 36517136
<?php

list($width,$height) = getimagesize('image.jpg');
$blackimage = imagecreate($width,$height);
imagecolorallocate($blackimage,0,0,0);

imagejpeg($blackimage,'image_black.jpg');

Open in new window


For more info:
http://www.php.net/imagecreate
http://www.php.net/getimagesize
http://www.php.net/imagecolorallocate
http://www.php.net/imagejpeg

HTH
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month21 days, 7 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question