Author Topic: Making images w/ PHP  (Read 879 times)

Offline CygnusX

  • Level 24
  • *
  • Posts: 303
  • Reputation: +3/-2
    • View Profile
    • Lords of Midnight
Making images w/ PHP
« on: May 10, 2011, 12:17:21 PM »
Has anyone ran into issues with PHP generating images?  I was making a simple progress bar, and got lazy and decided to make a full instances of my User class so I could pull a value from it in lieu of re-writing code that would pull the same value.  However, the image failed when making the class (the same code that works on all other pages).  I commented out header(), etc, to just 'run the code' to ensure it wasn't throwing any errors during imagine creation..... and nothing.  It 'appears' that calling this class was just for the image creator.  However, I suspect the problem is on my end, just hidden.  Any thoughts, similar stories, or recommendations?

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Making images w/ PHP
« Reply #1 on: May 11, 2011, 02:58:06 AM »
GD sux. It won't show you errors. Also some errors are not intuitive (some options do not work depending if the image is pallete based or true color). So the problem could be anywhere (you, GD, misunderstanding how it works, bad source image, bad mix of functions used).

Offline CygnusX

  • Level 24
  • *
  • Posts: 303
  • Reputation: +3/-2
    • View Profile
    • Lords of Midnight
Re: Making images w/ PHP
« Reply #2 on: May 11, 2011, 07:35:25 AM »
The odd thing is, my code works.  But if I open/call my user class (which works on all other pages without any errors that I am aware of), it suddenly fails.  So, the problem is isolated to something that happens when I construct my user class.  And the class isn't giving any errors...  so its just weird.

Offline BlackScorp

  • Level 15
  • *
  • Posts: 123
  • Reputation: +6/-0
    • View Profile
    • Cruel Online
Re: Making images w/ PHP
« Reply #3 on: May 12, 2011, 08:04:52 AM »
why do you generate images in php for Progressbar? i would make that with simple css somethink like this
http://jqueryui.com/demos/progressbar/

you just calculate your value of your progressbar in % and use this new value as position for a div

for example
<div class="progressbar container">
<div class="progressbar image" style="left:-20%"></div>
</div>


Offline CygnusX

  • Level 24
  • *
  • Posts: 303
  • Reputation: +3/-2
    • View Profile
    • Lords of Midnight
Re: Making images w/ PHP
« Reply #4 on: May 12, 2011, 03:27:16 PM »
I did not know jQuery had a progress bar.... but PHP just seems easier anyways.  That, and I wanted some custom details like hash marks at 1/8th increments. 

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Making images w/ PHP
« Reply #5 on: May 12, 2011, 03:43:18 PM »
If it's for things like HP bar then why not simple PHP+HTML? Trivial to make and ultra fast.

Offline CygnusX

  • Level 24
  • *
  • Posts: 303
  • Reputation: +3/-2
    • View Profile
    • Lords of Midnight
Re: Making images w/ PHP
« Reply #6 on: May 12, 2011, 04:28:06 PM »
Well... my assumption was that the PHP Gd library would give me the greatest flexibility for the time required.  I have written several programs that deal with image displays and knew a simple bar-graph would not be difficult (especially since I had old code I could recycle).  I've already found a work around.  Its just surprising the code failed and there is little to no way to diagnose why.

« Last Edit: May 13, 2011, 08:45:05 AM by CygnusX »

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Making images w/ PHP
« Reply #7 on: May 13, 2011, 03:10:24 AM »
Its just surprising the code failed and there is little to no way to diagnose why.
Welcome to GD :D

Offline BlackScorp

  • Level 15
  • *
  • Posts: 123
  • Reputation: +6/-0
    • View Profile
    • Cruel Online
Re: Making images w/ PHP
« Reply #8 on: May 17, 2011, 02:10:33 AM »
Well... my assumption was that the PHP Gd library would give me the greatest flexibility for the time required.  I have written several programs that deal with image displays and knew a simple bar-graph would not be difficult (especially since I had old code I could recycle).  I've already found a work around.  Its just surprising the code failed and there is little to no way to diagnose why.

i made the HP Bar with only JS ,HTML and CSS with jQuery UI Progessbar
http://teststation.kg-web.de/1523/gui/

as far as i know, browsergames should make less on servers and more on clients, else you will get much trouble if you have many users. i dont think that the GD Lib is good for display the HP Bar, i would use the GD Lib only to generate Forum Signature images for users.

greetz BlackScorp

sorry for my bad english:D registered here to learn it a bit

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Making images w/ PHP
« Reply #9 on: May 17, 2011, 02:19:20 AM »
as far as i know, browsergames should make less on servers and more on clients, else you will get much trouble if you have many users. i dont think that the GD Lib is good for display the HP Bar
Exactly. Using GD for this is a total misunderstanding.

Offline CygnusX

  • Level 24
  • *
  • Posts: 303
  • Reputation: +3/-2
    • View Profile
    • Lords of Midnight
Re: Making images w/ PHP
« Reply #10 on: May 17, 2011, 07:56:44 AM »
Perhaps... but when I hit such a large user base that my GD bargraph bogs down the server, I will comeback to this and other such threads to work on optimization. 

Offline BlackScorp

  • Level 15
  • *
  • Posts: 123
  • Reputation: +6/-0
    • View Profile
    • Cruel Online
Re: Making images w/ PHP
« Reply #11 on: May 17, 2011, 09:25:54 AM »
so why do you wait until it happends? make it right from the start and everythink will be fine then;)

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal