php-general Digest 27 Dec 2006 21:38:53 -0000 Issue 4537

Topics (messages 246231 through 246244):

Re: GD 2.0.28 + PHP 4.4.2 + pixelation :(
        246231 by: Peter Lauri
        246232 by: Jochem Maas
        246233 by: Steven Macintyre

PDFlib problem
        246234 by: Rosen
        246236 by: Peter Lauri
        246237 by: Jochem Maas
        246239 by: Rosen
        246241 by: Peter Lauri
        246242 by: Jochem Maas

Re: scripting process doesn't function
        246235 by: Jochem Maas
        246243 by: tedd

Simple PDF manipulation
        246238 by: Brian Dunning
        246240 by: tedd
        246244 by: Brian Dunning

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Hi,

imagecopyresampled might help you... I use that and it works without
problems.

/Peter

-----Original Message-----
From: Steven Macintyre [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 27, 2006 10:17 AM
To: php-general@lists.php.net
Subject: [PHP] GD 2.0.28 + PHP 4.4.2 + pixelation :(

Hi All,

I have done some searching via google and some answers say change
copyimageresampled to copyimageresized etc 

I have tried all fixes ... to no avail


I have one image here 1280 x 960 (150 dpi) 24 depth

When using the following it pixelates ... 

function createthumb($name,$filename,$new_w,$new_h)
{
        $system=explode(".",$name);
        $src_img=imagecreatefromjpeg($name);
        $old_x=imageSX($src_img);
        $old_y=imageSY($src_img);
        if ($old_x > $old_y)
        {
                $thumb_w=$new_w;
                $thumb_h=$old_y*($new_h/$old_x);
        }
        if ($old_x < $old_y)
        {
                $thumb_w=$old_x*($new_w/$old_y);
                $thumb_h=$new_h;
        }
        if ($old_x == $old_y)
        {
                $thumb_w=$new_w;
                $thumb_h=$new_h;
        }
        $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
        
imagecopyresized($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
        imagejpeg($dst_img,$filename);
        imagedestroy($dst_img);
        imagedestroy($src_img);
}

Which I am of course calling with
createthumb($add,'../pics/'.$largeval,350,263);

Now ... afaik my new sizes are proportional to the big ones ... but it
pixelates :(

However,

Using an image 1600 x 1200 (96 dpi) 24 depth it works and there is no
pixilation

Can someone perhaps assist now?


                                                          
Kind Regards,


Steven Macintyre
http://steven.macintyre.name
--

http://www.friends4friends.co.za

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Steven Macintyre wrote:
> Hi All,
> 
> I have done some searching via google and some answers say change
> copyimageresampled to copyimageresized etc 

which should be the correct; use copyimageresampled()

> 
> I have tried all fixes ... to no avail
> 
> 
> I have one image here 1280 x 960 (150 dpi) 24 depth

DPI is completely irrelevant.

the '24 depth' sounds like your using a PNG as input rather
that a JPEG (which your function expects)

your not making sure that the new width & height are always
integers. use intval() or ceil() or floor() (depending on your
your and the context)... I have no idea what happens if you pass
floats (or non-numeric data) in the relevant arguments of image*()
functinons but I'm guessing it *could* lead to unexplained weirdness
of some sort.

read the man page for imagejpeg():

        http://php.net/manual/en/function.imagejpeg.php

take note of the third argument, personally I always set it to 100,
anything less and clients have a tendency to start complaining about image
quality.


> 
> When using the following it pixelates ... 
> 
> function createthumb($name,$filename,$new_w,$new_h)
> {
>       $system=explode(".",$name);
>       $src_img=imagecreatefromjpeg($name);
>       $old_x=imageSX($src_img);
>       $old_y=imageSY($src_img);
>       if ($old_x > $old_y)
>       {
>               $thumb_w=$new_w;
>               $thumb_h=$old_y*($new_h/$old_x);
>       }
>       if ($old_x < $old_y)
>       {
>               $thumb_w=$old_x*($new_w/$old_y);
>               $thumb_h=$new_h;
>       }
>       if ($old_x == $old_y)
>       {
>               $thumb_w=$new_w;
>               $thumb_h=$new_h;
>       }
>       $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
>       
> imagecopyresized($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);

try: imagecopyresampled();

>       imagejpeg($dst_img,$filename);
>       imagedestroy($dst_img);
>       imagedestroy($src_img);
> }
> 
> Which I am of course calling with
> createthumb($add,'../pics/'.$largeval,350,263);
> 
> Now ... afaik my new sizes are proportional to the big ones ... but it
> pixelates :(
> 
> However,
> 
> Using an image 1600 x 1200 (96 dpi) 24 depth it works and there is no
> pixilation
> 
> Can someone perhaps assist now?
> 
> 
>                                                         
> Kind Regards,
> 
> 
> Steven Macintyre
> http://steven.macintyre.name
> --
> 
> http://www.friends4friends.co.za
> 

--- End Message ---
--- Begin Message ---
> imagecopyresampled might help you... I use that and it works
> without
> problems.
> 

Hi Peter,

" I have done some searching via google and some answers say change
copyimageresampled to copyimageresized etc"

I have tried your suggestion with the same results ... that is what I was
using first :(

S

--- End Message ---
--- Begin Message ---
Hi,
I have problem with PDFlib on Windows 2000, PHP 5.2.0 and Apache 2.2.3

When I try to execute:

$p = new PDFlib();

in the Apache log I receive:
PDFlib exception (fatal): [1202] PDF_set_parameter: Unknown key 'objorient'
[.....] [notice] Parent: child process exited with status 99 -- Restarting.

And nothing happens - I receive "Problem loading page".

Can someone help?

Thanks in advance,
Rosen

--- End Message ---
--- Begin Message ---
Try this one:

http://pecl.php.net/bugs/bug.php?id=9491&edit=1

/Peter

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free



-----Original Message-----
From: Rosen [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 27, 2006 2:58 PM
To: php-general@lists.php.net
Subject: [PHP] PDFlib problem

Hi,
I have problem with PDFlib on Windows 2000, PHP 5.2.0 and Apache 2.2.3

When I try to execute:

$p = new PDFlib();

in the Apache log I receive:
PDFlib exception (fatal): [1202] PDF_set_parameter: Unknown key 'objorient'
[.....] [notice] Parent: child process exited with status 99 -- Restarting.

And nothing happens - I receive "Problem loading page".

Can someone help?

Thanks in advance,
Rosen

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Rosen wrote:
> Hi,
> I have problem with PDFlib on Windows 2000, PHP 5.2.0 and Apache 2.2.3
> 
> When I try to execute:
> 
> $p = new PDFlib();
> 
> in the Apache log I receive:
> PDFlib exception (fatal): [1202] PDF_set_parameter: Unknown key 'objorient'
> [.....] [notice] Parent: child process exited with status 99 -- Restarting.
> 
> And nothing happens - I receive "Problem loading page".
> 
> Can someone help?

read this (it might help):

http://pecl.php.net/bugs/bug.php?id=9491&edit=1


basically, if your lucky, all you need to do is update PDFlib to a newer 
version.

> 
> Thanks in advance,
> Rosen
> 

--- End Message ---
--- Begin Message ---
Thank you all,
But from where I can download new version ( binary)  of  PDFlib  for windows 
?


""Rosen"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi,
> I have problem with PDFlib on Windows 2000, PHP 5.2.0 and Apache 2.2.3
>
> When I try to execute:
>
> $p = new PDFlib();
>
> in the Apache log I receive:
> PDFlib exception (fatal): [1202] PDF_set_parameter: Unknown key 
> 'objorient'
> [.....] [notice] Parent: child process exited with status 99 --  
> Restarting.
>
> And nothing happens - I receive "Problem loading page".
>
> Can someone help?
>
> Thanks in advance,
> Rosen 

--- End Message ---
--- Begin Message ---
http://www.pdflib.com/download/pdflib-family/pdflib-6/

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free

-----Original Message-----
From: Rosen [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 27, 2006 4:40 PM
To: php-general@lists.php.net
Subject: [PHP] Re: PDFlib problem

Thank you all,
But from where I can download new version ( binary)  of  PDFlib  for windows

?


""Rosen"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi,
> I have problem with PDFlib on Windows 2000, PHP 5.2.0 and Apache 2.2.3
>
> When I try to execute:
>
> $p = new PDFlib();
>
> in the Apache log I receive:
> PDFlib exception (fatal): [1202] PDF_set_parameter: Unknown key 
> 'objorient'
> [.....] [notice] Parent: child process exited with status 99 --  
> Restarting.
>
> And nothing happens - I receive "Problem loading page".
>
> Can someone help?
>
> Thanks in advance,
> Rosen 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Rosen wrote:
> Thank you all,
> But from where I can download new version ( binary)  of  PDFlib  for windows 
> ?

STFW: you could manage to type the words 'PDFlib download windows binary' (or 
something similar)
into the search box on the home page at google.com (or whatever search engine 
you prefer)???

http://www.pdflib.com/download/pdflib-family/pdflib-7/

> 
> 
> ""Rosen"" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> Hi,
>> I have problem with PDFlib on Windows 2000, PHP 5.2.0 and Apache 2.2.3
>>
>> When I try to execute:
>>
>> $p = new PDFlib();
>>
>> in the Apache log I receive:
>> PDFlib exception (fatal): [1202] PDF_set_parameter: Unknown key 
>> 'objorient'
>> [.....] [notice] Parent: child process exited with status 99 --  
>> Restarting.
>>
>> And nothing happens - I receive "Problem loading page".
>>
>> Can someone help?
>>
>> Thanks in advance,
>> Rosen 
> 

--- End Message ---
--- Begin Message ---
Geert T wrote:
> Hi,
>  
> I have made some script that process the users input, and validates the
> input and sends it back. But it doesn't work very
> well, in fact it doesn't work at all. I am only able to see and input my
> name and such in the html form, but the php part doesn't do it's job.

what exactly doesn't it do that you expect it to?

> I have looked over the scripts thousands of times, but couldn't find the
> problem, really.
>  
> Here is the script plus 2 .inc files;
>  
> Hoping for some replies and answers,
> Thanks in advance!
>  
> PS: if this script is a bit messy to read, 

.. it's because your not using plain text as your email format - highly 
annoying.

I have included them in this
> mail seperately.
>  
>  
> <?php
> /* Script name:  addressForm.inc
>  * Description: Script displays a form.
>  */
>  
>    echo "<html>
>     <head><title>Customer Address</title></head>
>     <body>";
>  echo "<p align='center'>
>     <form action='validateForm.php' method='POST'>

is 'validateForm.php' actually correct?

leave the 'action' blank to have it post to the current URL (regardless of
what it is.

>     <table width='95%' border='0' cellspacing='0'
>         cellpadding='2'\n";
>  foreach($labels as $field=>$value)
>  {
>   if(isset($_POST[$field]))
>   {
>    $value = $_POST[$field];
>   }
>   else
>   {
>    $value = "";
>   }
>   echo "<tr><td align='right'>{$labels[$field]}</br></td>
>      <td><input type='text' name'$field' size='65'
>         maxlength='65'
>       value='$value'> </td> </tr>";
>  }
>  echo " </table>
>      <div align='center'>
>        <p><input type='Submit' name='Submit'
>       value='Submit Address'></p></div>
>      </form>";
> ?>
> </body></html>
>  
>  
>  
>  
> <?php

I would consider an include file for a single, static, 7 item array
rather over-kill - not that it should be a problem either!

> /* Script name:  info.inc
>  * Description:  creates an array of labels for use in a
>  *     form.
>  */
>  $labels = array( "firstName"=>  "First Name:",
>       "midName"=>"Middle Name:",
>       "lastName"=>"Last Name:",
>       "street"=>"Street Address:",
>       "city"=>"City:",
>       "state"=>"State:",
>       "zipcode"=>"Zipcode:");
>      
> ?>
>  
>  
>  
> <?php
> /* Script name:  validateForm
>  * Description: Displays and validates a form that
>  *     collects a name and address.
>  */
>  

have you tried adding the following line to see what is being posted?:

var_dump($_POST, $_GET);

>   include("info.inc");         #6
>   #################################
>   ## First display of empty form ##
>   #################################
>   if(!isset($_POST['Submit']))        #10
>   {
>    include("addressForm.inc");
>   }
>   ########################################################
>   ## Check information when form is submitted. Build ##
>   ## arrays of blank and incorrectly formatted fields. ##
>   ## If any errors are found, display error messages ##
>   ## and redisplay form. If no errors found, display ##
>   ## the submitted information.    ##
>   ########################################################
>    else           #21
>    {
>      foreach($_POST as $field=>$value)      #23
>    {
>     if(empty($_POST[$field]))      #25
>   {
>      if($field !="midName")
>      {
>         $blanks[$field] = "blank";     #29
>      }
>   }
>   else         #33
>   {
>    $value = trim($value);
>    if($field != "zipcode")
>    {
>     if(!ereg("^[A-Za-z0-9' .-]{1,65}$",$value))
>     {
>      $formats[$field] = "bad";
>     }
>    }
>    elseif($field == "zipcode")
>    {
>     if(!ereg("^[0-9]{5}(\-[0-9]{4})?",$value))
>     {
>       $formats[$field] = "bad";
>     }
>    }
>   }
>  }          #51
>  ### if any fields were not okay, display error ###
>  ### message and redisplay form         ###

DONT STICK '@' IN FRONT OF FUNCTIONS (unless you *really* know
what you are doing - if that was the case I garantee you wouldn't have
needed post your question)

>  if (@sizeof($blanks) > 0 or @sizeof($formats) > 0)    #54
>  {
>    if (@size($blanks) > 0)
>    {
>      echo "<b>You didn't fill in one or more
>      required fields. You must enter:</b><br>";
>   foreach($blanks as $field => $value)
>   {
>     echo "&nbsp;&nbsp;&nbsp;{$labels[$field]}<br>";
>   }
>  }
>  if (@sizeof($formats) > 0)
>  { 
>    echo "<b>One or more fields have information that
>         appears to be incorrect. Correct the
>       format for:</b><br>";
>    foreach($formats as $field => $value)
>    {
>      echo "&nbsp;&nbsp;&nbsp;{$labels[$field]}<br>";
>    }
>  }
>  echo "<hr>";
>  include("adressForm.inc");
>   }
>   else
>   {
>      ### If no errors in the form, display the  ###
>  ### name and address submitted by user ###
>   echo "<html><head><title>Name and Address
>     </title></head><body>\n";
>   foreach($_POST as $field=>$value)
>   {
>    if($field != "Submit")
>   {
>     echo "{$labels[$field]} $value<br>\n";
>    }
>   }
>   echo "</body></html>";
>  }
>    } 
> ?>
>  
> 
> ------------------------------------------------------------------------
> Met MSN Spaces kun je per e-mail je weblog bijwerken. Publiceer leuke
> verhalen, foto's en meer! Het is gratis! Het is gratis!
> <http://clk.atdmt.com/MSN/go/msnnksac0030000001msn/direct/01/?href=http://www.imagine-msn.com/spaces>
> 
> 
> ------------------------------------------------------------------------
> 
> <?php
> /*    Script name:    addressForm.inc
>  *    Description:    Script displays a form.
>  */
>   
>       echo "<html>
>                 <head><title>Customer Address</title></head>
>                 <body>";
>       echo "<p align='center'>
>                 <form action='validateForm.php' method='POST'>
>                 <table width='95%' border='0' cellspacing='0'
>                                               cellpadding='2'\n";
>       foreach($labels as $field=>$value)
>       {
>               if(isset($_POST[$field]))
>               {
>                       $value = $_POST[$field];
>               }
>               else
>               {
>                       $value = "";
>               }
>               echo "<tr><td align='right'>{$labels[$field]}</br></td>
>                         <td><input type='text' name'$field' size='65'
>                                               maxlength='65'
>                                               value='$value'> </td> </tr>";
>       }
>       echo " </table>
>                  <div align='center'>
>                        <p><input type='Submit' name='Submit'
>                                       value='Submit Address'></p></div>
>                  </form>";
> ?>
> </body></html>
> 
> 
> ------------------------------------------------------------------------
> 
> <?php
> /* Script name:       info.inc
>  * Description:               creates an array of labels for use in a 
>  *                                    form.
>  */
> 
>       $labels = array( "firstName"=>   "First Name:",
>                                        "midName"=>"Middle Name:",
>                                        "lastName"=>"Last Name:",
>                                        "street"=>"Street Address:",
>                                        "city"=>"City:",
>                                        "state"=>"State:",
>                                        "zipcode"=>"Zipcode:");
>                                        
> ?>                             
> 

--- End Message ---
--- Begin Message ---
leave the 'action' blank to have it post to the current URL (regardless of
what it is.

Duh?

This is the new thing I learned today.

I've been messing around with _SERVER["SCRIPT_NAME"] and _SERVER["PHP_SELF"] just to make sure the code is portable -- and then you point out something I've been using for years with html.

Sometimes the details shadow what's in plain sight.

Thanks.

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message --- Let's say I have a complicated PDF document, like a Christmas card, that was made in Illustrator -- too complicated to easily create from scratch using PDFlib. Is there a way to use PHP make simple text changes - like changing "Dear XXX" to "Dear John"? I've opened the files with a text editor and cannot locate the simple text, it appears to be encoded somehow. The PDF has no security or encryption in it. Thanks....
--- End Message ---
--- Begin Message ---
At 6:32 AM -0800 12/27/06, Brian Dunning wrote:
Let's say I have a complicated PDF document, like a Christmas card, that was made in Illustrator -- too complicated to easily create from scratch using PDFlib. Is there a way to use PHP make simple text changes - like changing "Dear XXX" to "Dear John"? I've opened the files with a text editor and cannot locate the simple text, it appears to be encoded somehow. The PDF has no security or encryption in it. Thanks....

Brian:

I'm not saying that there is/isn't a way to do this, but I tried and failed.

In my investigation, I found that the insides of a PDF file are not conducive to a simple search and replace mechanism. The text is encoded in some fashion that is not easy to decode and reassemble.

The solution I came up with was to combine the existing PDF file with my coding and write over (on top of) the old to produce the new PDF that I wanted. In your case, take your Christmas Card with a big space where "xxx" appears and then write over that space with "John" in your new code.

I wish someone would show me a simpler way to do this.

hth's

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message --- Interesting, that's a good idea. I was not aware that it was possible to load an existing PDF into memory and then add stuff to it.


On Dec 27, 2006, at 7:28 AM, tedd wrote:

At 6:32 AM -0800 12/27/06, Brian Dunning wrote:
Let's say I have a complicated PDF document, like a Christmas card, that was made in Illustrator -- too complicated to easily create from scratch using PDFlib. Is there a way to use PHP make simple text changes - like changing "Dear XXX" to "Dear John"? I've opened the files with a text editor and cannot locate the simple text, it appears to be encoded somehow. The PDF has no security or encryption in it. Thanks....

Brian:

I'm not saying that there is/isn't a way to do this, but I tried and failed.

In my investigation, I found that the insides of a PDF file are not conducive to a simple search and replace mechanism. The text is encoded in some fashion that is not easy to decode and reassemble.

The solution I came up with was to combine the existing PDF file with my coding and write over (on top of) the old to produce the new PDF that I wanted. In your case, take your Christmas Card with a big space where "xxx" appears and then write over that space with "John" in your new code.

I wish someone would show me a simpler way to do this.

hth's

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---

Reply via email to