Solved

Make a solid black image

Posted on 2011-09-10
1
233 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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

912 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now