php-general Digest 1 May 2009 13:29:28 -0000 Issue 6097

Topics (messages 292168 through 292178):

Re: Two very useful PHP functions
        292168 by: Raymond Irving
        292172 by: Darren

ImageMagick
        292169 by: Michael A. Peters
        292170 by: Ashley Sheridan
        292171 by: Michael A. Peters
        292175 by: Kevin Waterson

Re: object literals
        292173 by: Richard Heyes
        292174 by: Peter Ford
        292177 by: Richard Heyes

Upload file name not file
        292176 by: MikeP
        292178 by: Simon

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

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


----------------------------------------------------------------------
--- Begin Message ---
Hi Colin and Daniel,

Thanks for the feedback.

I know that this functionality can be added to a framework or a stand alone 
function but I'm assuming that we would not get the same performance:

Case 1
-----------
$c = isset($a) ? $a : ''; 
// total time = overhead  of isset() + overhead of ?:

Case 2
-----------
$c = myWrapper($a,$b)  
// total time = overhead of myWrapper() + overhead of isset() + overhead of ?:

Case 3
-----------
$c = ifset($a,$b)  
// total time = overhead of ifset()



Best regards

__
Raymond Irving

--- On Thu, 4/30/09, Daniel Brown <danbr...@php.net> wrote:

> From: Daniel Brown <danbr...@php.net>
> Subject: Re: [PHP] Two very useful PHP functions
> To: "Raymond Irving" <xwis...@yahoo.com>
> Cc: php-gene...@lists.php.net
> Date: Thursday, April 30, 2009, 11:37 AM
> On Wed, Apr 29, 2009 at 22:32,
> Raymond Irving <xwis...@yahoo.com>
> wrote:
> >
> > What do you think? Can they make it into 5.3?
> 
>     Not when doing the ternary operator that you
> even displayed
> yourself takes up less code and time than a core function
> would.  It's
> a good idea, but better handled on the frontend of
> things.  You may
> want to consider contributing that to a framework, which is
> where it
> would be more appropriate.
> 
> -- 
> </Daniel P. Brown>
> daniel.br...@parasane.net
> || danbr...@php.net
> http://www.parasane.net/ || http://www.pilotpig.net/
> 50% Off All Shared Hosting Plans at PilotPig: Use Coupon
> DOW10000
>

--- End Message ---
--- Begin Message ---
This was discussed for PHP6, but eventually decided not to have such a
function. Instead, we now have the following:    $var = $_GET['var'] ?: 5;

Taken from http://www.corephp.co.uk/archives/19-Prepare-for-PHP-6.html

'you'd be able to do something like this: "$foo = $_GET['foo'] ?: 42;" (i.e.
if foo is true, $foo will equal 42).'


2009/5/1 Raymond Irving <xwis...@yahoo.com>

>
> Hi Colin and Daniel,
>
> Thanks for the feedback.
>
> I know that this functionality can be added to a framework or a stand alone
> function but I'm assuming that we would not get the same performance:
>
> Case 1
> -----------
> $c = isset($a) ? $a : '';
> // total time = overhead  of isset() + overhead of ?:
>
> Case 2
> -----------
> $c = myWrapper($a,$b)
> // total time = overhead of myWrapper() + overhead of isset() + overhead of
> ?:
>
> Case 3
> -----------
> $c = ifset($a,$b)
> // total time = overhead of ifset()
>
>
>
> Best regards
>
> __
> Raymond Irving
>
> --- On Thu, 4/30/09, Daniel Brown <danbr...@php.net> wrote:
>
> > From: Daniel Brown <danbr...@php.net>
> > Subject: Re: [PHP] Two very useful PHP functions
> > To: "Raymond Irving" <xwis...@yahoo.com>
> > Cc: php-gene...@lists.php.net
> > Date: Thursday, April 30, 2009, 11:37 AM
> > On Wed, Apr 29, 2009 at 22:32,
> > Raymond Irving <xwis...@yahoo.com>
> > wrote:
> > >
> > > What do you think? Can they make it into 5.3?
> >
> >     Not when doing the ternary operator that you
> > even displayed
> > yourself takes up less code and time than a core function
> > would.  It's
> > a good idea, but better handled on the frontend of
> > things.  You may
> > want to consider contributing that to a framework, which is
> > where it
> > would be more appropriate.
> >
> > --
> > </Daniel P. Brown>
> > daniel.br...@parasane.net
> > || danbr...@php.net
> > http://www.parasane.net/ || http://www.pilotpig.net/
> > 50% Off All Shared Hosting Plans at PilotPig: Use Coupon
> > DOW10000
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Here's the scenario -

Website has some demonstrative images.

I create these images with the gimp - starting with a jpeg, adding a few text layers and straight lines.

I then save as xcf in case I ever need to edit.

Then I export to jpeg, resize for thumb and export to jpeg again.

Admin interface to my web face needs to allow for upload of image.

What would be sweet is if I could just upload the gimp xcf in these cases, and have ImageMagick do the export to jpeg and thumbnail creation.

Advantage of doing it this way - it will allow me to keep the original xcf on the server along with the generated images.

Issues -

I'd rather not have any code that spawns a shell, so I can only do this if the pecl imageMagick module is up to snuff for xcf->jpeg conversion. Anyone used it? Looks like I'll have to compile it, before I do that I would like to know if it even is up to the task.

Second possible issue - I don't know how well imageMagick can deal with an xcf file that uses text layer / fonts. I assume I'll have to install the font used on the server (Adobe New Century Schoolbook Type 1 - yes, I have license for it), but if so, how would I specify to ImageMagick the font path?

Anyone done this sort of thing?

I may just do the export on my home box via gimp and just scp the xcf to the server so a copy is stored there as well, but it would be nice to just stick the xcf into a file upload field and just have php do the rest.
--- End Message ---
--- Begin Message ---
On Thu, 2009-04-30 at 23:35 -0700, Michael A. Peters wrote:
> Here's the scenario -
> 
> Website has some demonstrative images.
> 
> I create these images with the gimp - starting with a jpeg, adding a few 
> text layers and straight lines.
> 
> I then save as xcf in case I ever need to edit.
> 
> Then I export to jpeg, resize for thumb and export to jpeg again.
> 
> Admin interface to my web face needs to allow for upload of image.
> 
> What would be sweet is if I could just upload the gimp xcf in these 
> cases, and have ImageMagick do the export to jpeg and thumbnail creation.
> 
> Advantage of doing it this way - it will allow me to keep the original 
> xcf on the server along with the generated images.
> 
> Issues -
> 
> I'd rather not have any code that spawns a shell, so I can only do this 
> if the pecl imageMagick module is up to snuff for xcf->jpeg conversion. 
> Anyone used it? Looks like I'll have to compile it, before I do that I 
> would like to know if it even is up to the task.
> 
> Second possible issue - I don't know how well imageMagick can deal with 
> an xcf file that uses text layer / fonts. I assume I'll have to install 
> the font used on the server (Adobe New Century Schoolbook Type 1 - yes, 
> I have license for it), but if so, how would I specify to ImageMagick 
> the font path?
> 
> Anyone done this sort of thing?
> 
> I may just do the export on my home box via gimp and just scp the xcf to 
> the server so a copy is stored there as well, but it would be nice to 
> just stick the xcf into a file upload field and just have php do the rest.
> 
Do the text layers have to go beneath something on the original xcf, or
have special effects applied to them? If not, you can add t existing
images with GD, by using a source image, adding text layers, etc, and
then exporting it as a new graphic.


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
Ashley Sheridan wrote:


Do the text layers have to go beneath something on the original xcf, or
have special effects applied to them? If not, you can add t existing
images with GD, by using a source image, adding text layers, etc, and
then exporting it as a new graphic.

Yeah - I know I can do text with gd, I already do for some things.
The issue is that the placement of the text and the lines is custom per image, so it would require php coding each instance.

Some examples -

http://i142.photobucket.com/albums/r103/FunkyRes/8md.jpg
http://i142.photobucket.com/albums/r103/FunkyRes/telegans_shields02.jpg

Can be done with gd but it's a lot easier to add the text layers with a gui image editor - unless gimp has a php-gd export function that could write the code for me (that would be cool)
--- End Message ---
--- Begin Message ---
This one time, at band camp, Michael A. Peters wrote:
> Here's the scenario -
> 
> Website has some demonstrative images.
> 
> I create these images with the gimp - starting with a jpeg, adding a few 
> text layers and straight lines.
> 
> I then save as xcf in case I ever need to edit.
> 
> Then I export to jpeg, resize for thumb and export to jpeg again.


http://phpro.org/tutorials/Imagick.html

Kevin
http://phpro.org



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

>    $x = (object) array('a'=>1, 'b'=>3, ...);
>
> which works but isn't very lovely. it's neater in, for example, javascript.

Well, you could wrap it up in a function to make it a bit lovelier. Eg:

$foo = createObject(array('key' => 'value'));

It's not great, but PHP doesn't have a object literal syntax AFAIK.

-- 
Richard Heyes
HTML5 graphing: RGraph (www.rgraph.net)
PHP mail: RMail (www.phpguru.org/rmail)
PHP datagrid: RGrid (www.phpguru.org/rgrid)
PHP Template: RTemplate (www.phpguru.org/rtemplate)

--- End Message ---
--- Begin Message ---
Richard Heyes wrote:
> Hi,
> 
>>    $x = (object) array('a'=>1, 'b'=>3, ...);
>>
>> which works but isn't very lovely. it's neater in, for example, javascript.
> 
> Well, you could wrap it up in a function to make it a bit lovelier. Eg:
> 
> $foo = createObject(array('key' => 'value'));
> 
> It's not great, but PHP doesn't have a object literal syntax AFAIK.
> 
You could use JSON,

$foo = json_decode('{"a":1,"b":3}');

but I guess that's not much better than Richard's suggestion.

-- 
Peter Ford                              phone: 01580 893333
Developer                               fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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

> You could use JSON,
>
> $foo = json_decode('{"a":1,"b":3}');
>
> but I guess that's not much better than Richard's suggestion.

Didn't think of that (well... it's new). That's actually much better I
think, since you get the added boon of ease of portability to JS (if
that's even a factor).

-- 
Richard Heyes
HTML5 graphing: RGraph (www.rgraph.net)
PHP mail: RMail (www.phpguru.org/rmail)
PHP datagrid: RGrid (www.phpguru.org/rgrid)
PHP Template: RTemplate (www.phpguru.org/rtemplate)

--- End Message ---
--- Begin Message ---
Hello,
Id like to use the popup file system box(<input name="userfile" type="file" 
/>) to choose a file name , but I only want to upload the filename , not the 
file. Can I do that?
Thanks
Mike 



--- End Message ---
--- Begin Message ---
> Id like to use the popup file system box(<input name="userfile" type="file"
> />) to choose a file name , but I only want to upload the filename , not the
> file. Can I do that?

You're not supposed to have any access to the remote visitor's
computer, and the path to the file being uploaded could contain
sensitive information (ie. like username of windows user).  There are
ways to get the information, even to read information on disk without
the use of a file upload form.  But they are/will be considered like
security threats and are/will be closed down.

IMO, whatever way you find to get this information is meant 1) not to
be portable accross different browsers and 2) to stop working
eventually.  (Of course unless you ask the user to explicitly type the
path in a text input)

What do you need this for?

--- End Message ---

Reply via email to