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
Solved

Make a solid black image

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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…
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.

856 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