473,394 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

WBMP output doesn't work

Hello, I'm having a probelm output wbmp images. Something seems to keep
going wrong with the encoding, because I start with a good jpeg and get
a nonworking wbmp on the other end.

here is my code:

$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width,
$new_height, $width, $height);

// Output new image
imagewbmp($image_p, "..path..");
Replacing the imagewbmp with imagejpeg will output a valid jpeg file,
or I can output a valid PNG as well. But outputing a wbmp never works,
I get a busted image. Anyone know what's going on here? Am I missing
some color conversion step?

Aug 6 '05 #1
3 1845
I checked the gd_info() and wbmp support is enabled, btw.

Aug 6 '05 #2
On 5 Aug 2005 18:25:07 -0700, "AaronV" <aa**************@gmail.com> wrote:
Hello, I'm having a probelm output wbmp images. Something seems to keep
going wrong with the encoding, because I start with a good jpeg and get
a nonworking wbmp on the other end.

here is my code:

$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width,
$new_height, $width, $height);

// Output new image
imagewbmp($image_p, "..path..");
Replacing the imagewbmp with imagejpeg will output a valid jpeg file,
or I can output a valid PNG as well. But outputing a wbmp never works,
I get a busted image. Anyone know what's going on here? Am I missing
some color conversion step?


OK, in what way is it busted?

Zero length file? Or actually producing a corrupted file in some way?

Anything obvious in the file itself like error messages? (Presumably not since
it's using the path argument in the GD call, but worth a quick look).

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Aug 6 '05 #3
AaronV wrote:
Replacing the imagewbmp with imagejpeg will output a valid jpeg file,
or I can output a valid PNG as well. But outputing a wbmp never works,
I get a busted image. Anyone know what's going on here? Am I missing
some color conversion step?


The problem is that WBMP can only be created from images which contain black
and white only.

The imagetruecolortopalette() function seems to be able to reduce the color
depth, but the result will still be insufficient to create a WBMP image,
because it will not consist of just black and white.

One solution is to map the pixels to either black or white manually. You
will need to to this after you have resampled the image and before you call
imagewbmp().

The following code produced reasonable results with the images I have tested
it with:

for ($y = 0; $y < $new_height; $y++) {
for ($x = 0; $x < $new_width; $x++) {
$colors = imagecolorsforindex(
$image_p,
imagecolorat($image_p, $x, $y)
);

if ($colors['red'] > 180) {
$color = imagecolorallocate($image_p, 255, 255, 255);
} else {
$color = imagecolorallocate($image_p, 0, 0, 0);
}
imagesetpixel($image_p, $x, $y, $color);
}
}

As I said, you should insert this code just after you have called
imagecopyresampled() and before calling imagewbmp().
HTH;
JW

Aug 6 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Steve | last post by:
Hi; Before I start let me say I know this is a silly way to go about things, but it is one of those "my company made me do it" things. My company is in the process of ( finishing ) migrating...
12
by: Matt Garman | last post by:
I'd like to create a "custom output facility". In other words, I want an object whose use is similar to std::cout/std::cerr, but offers more flexibility. Instead of simply writing the parameter...
6
by: Patrik | last post by:
I know this has been dealt with a lot, but I would still really appreciate help. Thanks. I am trying to transform this table YY--ID-Code-R1-R2-R3-R4...R40 2004-1-101--1--2-3-4...
2
by: Genival Carvalho | last post by:
I need a function or component ( free - with source if possible ) to convert images like BMP, JPG, etc into wbmp. ThankZ... Genival - Sao Paulo - BR
2
by: Sara T. | last post by:
Is there a way to display image with format WBMP in VB.NET? I've just only found the other format i.e. *.gif, *.jpg. Sara T.
5
by: Paul Bergson | last post by:
I have been trying to get a process to start up and run with arguments passed to it. I have gotten close (Thanks to help from this board) but I there is a failure while I'm running this because...
2
by: Will Rickards | last post by:
In my web application there is an interactive report. Then there need to be a printable version a pdf. So I found this java tool csstoxslfo and the java fop tool from apache that will take my...
6
by: Alec MacLean | last post by:
Hi, I've created a small application for our company extranet (staff bulletins) that outputs a list of links to PDF's that are stored in a SQL table. The user clicks a link and the PDF is...
6
by: =?Utf-8?B?R3JlZw==?= | last post by:
I am using the following command to output my results to the Output window (for testing things out). Console.WriteLine ("Output") I'd like to clear the Output window of any previous output. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.