473,581 Members | 6,775 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 = imagecreatetrue color($new_widt h, $new_height);
$image = imagecreatefrom jpeg($filename) ;
imagecopyresamp led($image_p, $image, 0, 0, 0, 0, $new_width,
$new_height, $width, $height);

// Output new image
imagewbmp($imag e_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 1852
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 = imagecreatetrue color($new_widt h, $new_height);
$image = imagecreatefrom jpeg($filename) ;
imagecopyresam pled($image_p, $image, 0, 0, 0, 0, $new_width,
$new_height, $width, $height);

// Output new image
imagewbmp($ima ge_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.andyhsoftwa re.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 imagetruecolort opalette() 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 = imagecolorsfori ndex(
$image_p,
imagecolorat($i mage_p, $x, $y)
);

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

As I said, you should insert this code just after you have called
imagecopyresamp led() 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
2937
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 from foxpro to sqlserver. They have a foxpro program that does a lot of various updates. I would like to write a tsql script to replace it.
12
3195
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 to stdout/stderr, I'd like it to write to stdout, to a file, and/or call a logging function. So my output function might look something like this:...
6
2878
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 2004-2-101--2--3-4-2 .... 2005-99-103-4-3-2-1
2
3090
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
1111
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
2063
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 the c:\bin\xcacls starts nothing happens. How can I see output from the console i was trying to get the ProcessStartInfo.RedirectStandardOutput...
2
2144
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 xhtml and css and convert it to pdf. Problem 1) I designed the aspx page to produce the xhtml as output. So how do I save that rendered page to a...
6
4904
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 loaded into a new browser window. This works as expected on the test PC (using forms authentication, but no SSL) using IE. It also works as expected...
6
3455
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 tried Console.Clear but, this results in an error.
0
7854
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8134
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8296
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7880
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8157
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6539
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5665
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5350
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.