?
Solved

Make a solid black image

Posted on 2011-09-10
1
Medium Priority
?
238 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to implement server side field validation and display customized error messages to the client.
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 count occurrences of each item in an array.
Suggested Courses

771 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