PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.php > How to save PNG image
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
How to save PNG image

Réponse
 
LinkBack Outils de la discussion
Vieux 11/12/2007, 17h16   #1
hol
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut How to save PNG image

Hi,

I have some PHP code that creates a PNG image.
All I want is to have a button that saves the created image to the user's
hard disk.
I need this since a lot of people do not know that they can right click on
the image and save it.

Thansk beforehand.

Mark


  Réponse avec citation
Vieux 11/12/2007, 17h29   #2
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to save PNG image


"hol" <contact7@hol.gr> wrote in message
news:fjmgkg$gsa$1@newsmaster.pub.dc.hol.net...
> Hi,
>
> I have some PHP code that creates a PNG image.
> All I want is to have a button that saves the created image to the user's
> hard disk.
> I need this since a lot of people do not know that they can right click on
> the image and save it.


an href with a specific target can call your php png image creation script
simply when the user clicks the link. all your creation script need do is
set the content-type and content-disposition. your browser takes care of
asking the user if they want to open it or save it.

> Thansk beforehand.


you're welcome afterhand.


  Réponse avec citation
Vieux 11/12/2007, 17h44   #3
hol
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to save PNG image

Thanks Steve,

What you suggest is a simple solution to my problem.
The dissadvantage of the method is that the php script that creates the
image, takes quite some time to execute since it collects data from a rather
big database.
Therefore I was thinking that since the image has been already created, I
wouldn't have to recreate it.

Any ideas?


Ï "Steve" <no.one@example.com> Ýãñáøå óôï ìÞíõìá
news:ZNz7j.31$%91.30@newsfe05.lga...
>
> "hol" <contact7@hol.gr> wrote in message
> news:fjmgkg$gsa$1@newsmaster.pub.dc.hol.net...
>> Hi,
>>
>> I have some PHP code that creates a PNG image.
>> All I want is to have a button that saves the created image to the user's
>> hard disk.
>> I need this since a lot of people do not know that they can right click
>> on the image and save it.

>
> an href with a specific target can call your php png image creation script
> simply when the user clicks the link. all your creation script need do is
> set the content-type and content-disposition. your browser takes care of
> asking the user if they want to open it or save it.
>
>> Thansk beforehand.

>
> you're welcome afterhand.
>



  Réponse avec citation
Vieux 11/12/2007, 18h00   #4
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to save PNG image


"hol" <contact7@hol.gr> wrote in message
news:fjmi9b$gsa$2@newsmaster.pub.dc.hol.net...
> Thanks Steve,
>
> What you suggest is a simple solution to my problem.
> The dissadvantage of the method is that the php script that creates the
> image, takes quite some time to execute since it collects data from a
> rather big database.
> Therefore I was thinking that since the image has been already created, I
> wouldn't have to recreate it.
>
> Any ideas?


i have to start then by stating the obvious...create the image once (based
on your constraints...big db, etc.), save it to the *server's* hd, show it
in the browser...surrounding the image in an href that points to the image
on the server and make the href have a specific target.

how you decide to manage the archival or deletion of the images on the
server would be up to you.

if there's something more complex you had in mind, let me know.


  Réponse avec citation
Vieux 11/12/2007, 18h29   #5
J.O. Aho
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to save PNG image

hol wrote:
> Thanks Steve,
>
> What you suggest is a simple solution to my problem.
> The dissadvantage of the method is that the php script that creates the
> image, takes quite some time to execute since it collects data from a rather
> big database.
> Therefore I was thinking that since the image has been already created, I
> wouldn't have to recreate it.


1. Check if the file is on the local hard drive with file_exists()

2a. if not, create the image and save it to hard drive
2b. load the already created image into your script

3. spit out the image with the proper headers.


This is how we do at my work, first time any user enter a page, the script
generates the previews in the right size, this first load usually takes longer
time, but any visit after that goes quite fast as no need to create the images.

--

//Aho
  Réponse avec citation
Vieux 11/12/2007, 19h24   #6
hol
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to save PNG image

Thanks for your J.O. Aho & Steve

Unfortunatelly this solution does not really work for me.

To explain the situation better let me tell you that the user of this site
has the opportunity to collect specific data from a huge database, and
create some diagrams on the spot.
The number of different diagrams is unlimited since there are many different
parameters. That is why I cannot store those images on the server.

I just need the users to be able to store an image that has been created
there and then on their hard disk.

Thank you for your valuable .


? "J.O. Aho" <user@example.net> ?????? ??? ??????
news:5s837tF181015U1@mid.individual.net...
> hol wrote:
>> Thanks Steve,
>>
>> What you suggest is a simple solution to my problem.
>> The dissadvantage of the method is that the php script that creates the
>> image, takes quite some time to execute since it collects data from a
>> rather
>> big database.
>> Therefore I was thinking that since the image has been already created, I
>> wouldn't have to recreate it.

>
> 1. Check if the file is on the local hard drive with file_exists()
>
> 2a. if not, create the image and save it to hard drive
> 2b. load the already created image into your script
>
> 3. spit out the image with the proper headers.
>
>
> This is how we do at my work, first time any user enter a page, the script
> generates the previews in the right size, this first load usually takes
> longer
> time, but any visit after that goes quite fast as no need to create the
> images.
>
> --
>
> //Aho



  Réponse avec citation
Vieux 11/12/2007, 20h13   #7
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to save PNG image


"hol" <contact7@hol.gr> wrote in message
news:fjmo52$gsa$3@newsmaster.pub.dc.hol.net...
> Thanks for your J.O. Aho & Steve
>
> Unfortunatelly this solution does not really work for me.
>
> To explain the situation better let me tell you that the user of this site
> has the opportunity to collect specific data from a huge database, and
> create some diagrams on the spot.
> The number of different diagrams is unlimited since there are many
> different parameters. That is why I cannot store those images on the
> server.


please explain. you can certainly store those images on the server and
associate them with that user and the diagram he's generating. i don't see
the problem here.

> I just need the users to be able to store an image that has been created
> there and then on their hard disk.


the way in which aho and i have described is your only way to do this unless
you choose to dynamically generate it more than once. the only other
alternative would be to tell them specifically to right-click the image and
choose save. you cannot do this for them using javascript or some other
scripting language on the client side...i.e. their browser. so, you're stuck
managing your options on the server.

best of luck.


  Réponse avec citation
Vieux 13/12/2007, 01h32   #8
NC
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to save PNG image

On Dec 11, 11:24 am, "hol" <conta...@hol.gr> wrote:
>
> The number of different diagrams is unlimited since there
> are many different parameters. That is why I cannot store
> those images on the server.


Of course you can... Just name the files uniquely (say, using
uniqid()) and keep deleting image files that are more than an hour
(day, week, month) old.

> I just need the users to be able to store an image that
> has been created there and then on their hard disk.


So here are your choices, (1) regenerate (which you don't want to do,
because it takes time), or (2) save to the server's file system (which
you don't want to do, because it takes disk space). There is no third
option.

Cheers,
NC
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h37.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,15812 seconds with 16 queries