Talk Arcades: Forum for Arcade Webmasters    

  Talk Arcades > Community > Talk Arcades

Welcome to Talk Arcades, the premier forum for arcade webmasters.

You are currently viewing our boards as a guest. By joining our community you will be able to make posts, communicate privately with other arcade webmasters and participate in our Live Marketplace. Registration is easy, so please join us today!

Reply
 
LinkBack Thread Tools Display Modes
Old 07-08-2008, 09:36 AM   #1 (permalink)
David.R
Contributing Member
 
Join Date: Nov 2006
Posts: 31
David.R is on a distinguished road


Question How to use php get SWF files size ?

Any guys can help give some advice ?

I just try to use php get SWF files size renew all my game size in the Databases possible.

thanks all
David.R is offline  
Digg this Post!
Reply With Quote
Old 07-08-2008, 11:25 AM   #2 (permalink)
hawkal
Senior Member
 
Join Date: May 2007
Posts: 211
hawkal is on a distinguished road


Default

I am assuming by file size you mean dimensions (width/height) of the game and not the size as in number of bytes.

This looks like the sort of thing your looking for. Please note that this code was written off the top of my head and has not be tested at all so it probably has errors. If your try it I suggest that you backup your database before doing so.

PHP Code:
<?php
mysql_connect
('localhost''username''password') or die(mysql_error()); 

mysql_select_db('database')or die(mysql_error()); 

$query mysql_query("SELECT `filename` from games");

while(
$row =  mysql_fectch_array($query){  // loop through the filenames in your db

$size getimagesize("pathto/yourswffiles/$row['filename']"); //you may need to add 
//the file extention here because some scripts 
//(gamescript for example) don't have file extentions in the database  

$width $size[0]; 
$height $size[1]; 

if(
$width == "0") {  // If a size isn't set give it one of your choice
            
$width "500"
            
$height "300";
        }  

if(
$width "700"  && $height "1000"){ // you may want to set a maximum size 
    
$width "700"
    
$height "1000";
}       
      
     
mysql_query("UPDATE games SET width=$width AND height= $height
 WHERE filename=$row['filename'] LIMIT 1"
)or die(mysql_error());
 

?>

If you just wanted to know specifically how to get swf dimensions then its the function "getimagesize()" and the width and height are the first two values in the array [0](width) [1](height)


I hope it works and helps. If not just say so here.

EDIT: made a few changes. noticed I had "or die(mysql_error()) twice at the last sql query.
__________________
www.ownage.us

www.Allarcade.us


Last edited by hawkal : 07-09-2008 at 07:49 AM.
hawkal is offline  
Digg this Post!
Reply With Quote
Old 07-08-2008, 08:17 PM   #3 (permalink)
David.R
Contributing Member
 
Join Date: Nov 2006
Posts: 31
David.R is on a distinguished road


Default

thanks guys , but I'm wondering ... The $size return always "blank" , it's nothing ... any special setup in php.ini need ? thanks
David.R is offline  
Digg this Post!
Reply With Quote
Old 07-09-2008, 05:44 AM   #4 (permalink)
ArcadeSiteBuilder
Senior Member
 
Join Date: Oct 2007
Posts: 211
ArcadeSiteBuilder is on a distinguished road
Send a message via MSN to ArcadeSiteBuilder


Default

Hawkal that's a nice script. I have one that I had written for me a few months ago. I added a field to games table that signifies if the game file has been resized, if it has then the script ignores it and I had a timeout built inbetween each game load to relieve server load issues. A thousand games takes about 4 hours with 15 second interval.

I like your idea about setting default sizes when condition are met.


Good idea to add conditions to eliminate video files and dcr files too!
__________________

ArcadeSiteBuilder is online now  
Digg this Post!
Reply With Quote
Old 07-09-2008, 08:21 AM   #5 (permalink)
hawkal
Senior Member
 
Join Date: May 2007
Posts: 211
hawkal is on a distinguished road


Default

Quote:
thanks guys , but I'm wondering ... The $size return always "blank" , it's nothing ... any special setup in php.ini need ? thanks
Your welcome. If your just trying to echo $size it won't work because it is an array, you have to specify which one you want so $size[0] would be width and $size[1] would be hight in the script I written. There should not be any reason it wouldn't work as far as I'm aware.


Quote:
Hawkal that's a nice script. I have one that I had written for me a few months ago. I added a field to games table that signifies if the game file has been resized, if it has then the script ignores it and I had a timeout built inbetween each game load to relieve server load issues. A thousand games takes about 4 hours with 15 second interval.

I like your idea about setting default sizes when condition are met.


Good idea to add conditions to eliminate video files and dcr files too!
Thanks.

That's a good idea, did you have it check to see if it resized just incase the script terminated? or it would be useful on a host that limits script execution time.

Another way you could relieve the server would be to limit the amount of games you resize at a time.


I agree it is a good idea to check for video and dcr files and it would be quite easy for scripts that have the extention in the filename in the db. I might add more to it later on.





__________________
www.ownage.us

www.Allarcade.us

hawkal is offline  
Digg this Post!
Reply With Quote
Old 07-09-2008, 08:38 AM   #6 (permalink)
ArcadeSiteBuilder
Senior Member
 
Join Date: Oct 2007
Posts: 211
ArcadeSiteBuilder is on a distinguished road
Send a message via MSN to ArcadeSiteBuilder


Default

Quote:
Originally Posted by hawkal View Post


That's a good idea, did you have it check to see if it resized just incase the script terminated? or it would be useful on a host that limits script execution time.

Another way you could relieve the server would be to limit the amount of games you resize at a time.


I agree it is a good idea to check for video and dcr files and it would be quite easy for scripts that have the extension in the filename in the db. I might add more to it later on.


In the new field I created I set the value to "NO" when the script I have records to the database it then also changes checked field to have value "YES" . The script excludes those in it's original query.

phpas records the file type in separate field ... many scripts do. So to pick up just swf files need to find file type "1"

I also have a neat script that resizes video files ... that one took some time as it requires a new library to be installed but man is it nice.
__________________

ArcadeSiteBuilder is online now  
Digg this Post!
Reply With Quote
Old 07-09-2008, 03:36 PM   #7 (permalink)
hawkal
Senior Member
 
Join Date: May 2007
Posts: 211
hawkal is on a distinguished road


Default

At least phpas has the right idea, like I said earlier gamescript doesn't do that so it has to get the file extensions on the fly every time a game is loaded.

Yea it's ffmpeg isn't it? Never used it myself, I remember someone on the gamescript forums talking about changing .wmv files to .flv on the fly with ffmpeg so that they could use a flash player.
__________________
www.ownage.us

www.Allarcade.us

hawkal is offline  
Digg this Post!
Reply With Quote
Old 07-09-2008, 08:36 PM   #8 (permalink)
David.R
Contributing Member
 
Join Date: Nov 2006
Posts: 31
David.R is on a distinguished road


Default

I still fail... running this script , 95% swf files get w=0 h=0 lol use PAS .
David.R is offline  
Digg this Post!
Reply With Quote
Old 07-10-2008, 07:54 AM   #9 (permalink)
hawkal
Senior Member
 
Join Date: May 2007
Posts: 211
hawkal is on a distinguished road


Default

Strange, even if it isn't able to get the file dimensions it should still set it to the chosen default.

Are you using the exact script I provided or have you modified it at all? (A part from sql info and the path to your .swf files of course.)
__________________
www.ownage.us

www.Allarcade.us

hawkal is offline  
Digg this Post!
Reply With Quote
Old 07-10-2008, 11:59 AM   #10 (permalink)
David.R
Contributing Member
 
Join Date: Nov 2006
Posts: 31
David.R is on a distinguished road


Default

Yes , it's 95% got default lol . Are you sure ? or something wrong with me server setup ?
David.R is offline  
Digg this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
The Most Powerful Windows Application Creature The Lounge 0 06-19-2006 04:02 AM


All times are GMT -6. The time now is 02:36 PM.


Powered by vBulletin® Version 3.6.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0 RC6
© TalkArcades.com
Forum - Register - Calendar - Memberlist - FAQ - Search