Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting images (PCX to...)

Status
Not open for further replies.

BB101

Programmer
May 23, 2001
337
GB
I'm writing a reporting system and I have a problem.

I need to insert PCXs into a PDF (using PDFLib), but it doesn't support PCXs.

So, to get round the problem, I need to convert the PCXs to JPGs or GIFs

Does anyone know of a piece of PHP that can do this inline, (by that I mean, can be called and run in PHP script), because the images will have additions and modifications on a regular basis; and they come as PCXs.

Anyone? --BB
 
I recommend you take a look at ImageMagick (
You will have to use exec() to invoke ImageMagick's convert function, but it should be able to convert your PCXs to the format you need. ______________________________________________________________________
My God! It's full of stars!
______________________________________________________________________
 
Duff url it seems... ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
thanks, installed and working!

--BB --BB
 
I now have another problem.

I assembled a batch file to get into the right drive/directory, and run the convert on the pcx's.

Run from the command prompt works superbly, but run in from PHP, it doesn't do anything.

The batch file is only 3 lines long and I see NO reason it shouldn't work.

All I am doing is exec($cmd);

The batch file is located in the same dir as the PHP file and it IS running

Help? --BB
 
I think batch files are executed by cmd.exe or some other program that handles the DOS stuff in Windows. Though PHP doesn't send these commands to the DOS handling program, it executes the program directly. Hence, I don't think a batch file would work. //Daniel
 
How do I make it work?

All I need to do is change drive, change directory and run this program.

The program doesn't accept folders (or files) with spaces in the name, so moving to that dir within the cmd itself would seem to be the best alternative, however I found executing 2/3 things at once with exec impossible, so now im trying with a batch file.

help.

If I get this bugger to work I'll have a nice PDF making uber website of death! --BB
 
On a Win32 box, do "dir /x". It'll show you the short directory names (the stuff like "progra~1" instead of "Program Files").

Use those short directory names instead of the long ones. ______________________________________________________________________
My God! It's full of stars!
______________________________________________________________________
 
That would be a minor hassle, I would have to dir every folder on the way checking the dos name... would be pretty slow too --BB
 
Either the directory tree pre-exists, in which case you can determine the short names in advance, or you are creating the directory tree as you go, in which case you can create names in the 8.3 format. ______________________________________________________________________
My God! It's full of stars!
______________________________________________________________________
 
The directory tree exists already and it will be added to. The folder names with spaces are chapter x where x is a number between 1 and 99 (or so).

I can't pre-ordane which is which, so please help!

All i need to do is change dir and run a program --BB
 
If the option of renaming the directories "chap01" through "chap99", respectively, is not an option, here's what I would do:

At a command prompt, go to the parent of your 99 chapter directories. Perform "dir /ad/x > dirnames.txt"

Edit dirnames.txt so that it is a PHP script which initializes a variable to an associative array, the keys being the long filennames, the values being the short filenames. My file ended up looking like:

[tt]<?php
$dirnames = array (
&quot;chapter 1&quot; => &quot;CHAPTE~1&quot;,
&quot;chapter 2&quot; => &quot;CHAPTE~2&quot;,
&quot;chapter 3&quot; => &quot;CHAPTE~3&quot;,
&quot;chapter 4&quot; => &quot;CHAPTE~4&quot;,
&quot;chapter 5&quot; => &quot;CHD8DD~1&quot;,
.
.
.
);
?>
[tt]
Notice that the dir command presented the short and long directory names in the wrong order. You'll have to reverse them, because you want the keys of the array to be the long filenames.

Save the file as dirnames.php. Use the include() statement in your scripts to include dirnames.php. The array variable (in my case $dirnames) is now a translation table between the long filenames and the short filenames. ______________________________________________________________________
My God! It's full of stars!
______________________________________________________________________
 
It's ok, I got imagemagick working properly with long file names and all is good again :eek:P --BB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top