Solved

Make a solid black image

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Not needed 13 58
php connect() failed error 25 17
Change password through link 1 13
PHP JSON Clean up 5 10
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

744 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

14 Experts available now in Live!

Get 1:1 Help Now