Jump to content

aNubies

Members
  • Posts

    31
  • Joined

  • Last visited

Posts posted by aNubies

  1. Alright im testing the imagecreatefromstring() function, but it always give me an error saying "data is not recognized format". This is base on my previous post that what i want to do is convert my .pix file which is a map file into a jpeg file.

     

    I tried to read the stream before converting it into the function but no luck, same with file_get_contents but no luck also.

     

    Help here please. Thank you in advance.

  2. Okay, now my mind is open with imagecreafrom (png, jpeg, gif) function of PHP. But i'm curious does it support other image format? ofcourse it is a very obvious question seeing those 3 are the only available function, but this is just curiosity.

     

    Since I'm planning to reduce and re-scale a sattelite image which is in ".pix" format a type of image file but with a different format.

    So is it possible?

     

    Those who work in maps, satellites is very much appreciated or anyone :).

     

    Thank you very much in advance.

  3. Here's my current code.

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title> Reduce & Resize Images </title>
    
    <?php
    	function CheckDirectory() {
    		$netDir = "Network_Images/*.png";
    		$locDir = "Local_Images/";
    		
    		foreach (glob($netDir) as $net) {
    			$files = glob($locDir."/".substr($net, strpos($net, "/") + 1));
    			if (empty($files)) {
    				$im = imagecreatefrompng($net);
    				$new_image = imagecreatetruecolor(50, 50);
    				imagecopyresampled($new_image, $im, 0, 0, 0, 0, 50, 50, imagesx($im), imagesy($im));
    				$im = $new_image;
    				imagepng($im, $locDir.substr($net, strpos($net, "/") + 1), 0);
    			}
    		}
    	}
    ?>
    
    <script type="text/javascript">
    	function init() {
    		console.log("timeout called");
    		document.write("<?php CheckDirectory(); ?>");
    		t = setTimeout(function() {init()}, 30000);
    	}
    </script>
    
    </head>
    <body onload="init()">
    
    <form action="" method="POST" enctype="multipart/form-data">
    	<label name="lblBrowser">Filename :   </label>
        <input type="file" name="fileUpload" id="fileUpload" /><br />
    
        <input type="submit" value="Upload" id="Upload" />
    </form>
    
    </body>
    </html>
    
  4. Okay after observing something in console and page source, looks like the reason is that after executing it once the source turns into this <document.write("");> at first <document.write("phpcode");> and it turns into nothing. Is it saying that javascript cannot run server side code, but instead use AJAX?

     

    Anyone please help me out here.

  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title> Reduce & Resize Images </title>
    
    <?php
    	function CheckDirectory() {
    		$netDir = "Network_Images/*.png";
    		$locDir = "Local_Images/";
    		
    		foreach (glob($netDir) as $net) {
    			$files = glob($locDir."/".substr($net, strpos($net, "/") + 1));
    			if (empty($files)) {
    				$im = imagecreatefrompng($net);
    				$new_image = imagecreatetruecolor(50, 50);
    				imagecopyresampled($new_image, $im, 0, 0, 0, 0, 50, 50, imagesx($im), imagesy($im));
    				$im = $new_image;
    				imagepng($im, $locDir.substr($net, strpos($net, "/") + 1), 0);
    			}
    		}
    		exit();
    	}
    ?>
    
    <script type="text/javascript">
    	function init() {
    		document.write("<?php CheckDirectory(); ?>");
    		t = setTimeout(function() {init()}, 30000);
    	}
    </script>
    
    </head>
    <body onload="init()">
    
    <form action="" method="POST" enctype="multipart/form-data">
    	<label name="lblBrowser">Filename :   </label>
        <input type="file" name="fileUpload" id="fileUpload" /><br />
    
        <input type="submit" value="Upload" id="Upload" />
    </form>
    
    </body>
    </html>
    

     

    Here's the corrected CheckDrirectory->CheckDirectory.

  6. Well CheckDirectory() function does check if the image is exist in the other folder, if its not it will create a copy. So basically i need it to execute continously base on the time i set.

     

    The code above just execute at first time around only dunno why.

     

    [EDIT]

     

    Oh, I see the typo of CheckDirectory spelling, my bad.

  7. Okay, I manage to make a function checkdirectory and execute it using javascript but what i want is execute it base on the time I set. But with my current code it just execute once.

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title> Reduce & Resize Images </title>
    
    <?php
    	function CheckDrirectory() {
    		$netDir = "Network_Images/*.png";
    		$locDir = "Local_Images/";
    		
    		foreach (glob($netDir) as $net) {
    			$files = glob($locDir."/".substr($net, strpos($net, "/") + 1));
    			if (empty($files)) {
    				$im = imagecreatefrompng($net);
    				$new_image = imagecreatetruecolor(50, 50);
    				imagecopyresampled($new_image, $im, 0, 0, 0, 0, 50, 50, imagesx($im), imagesy($im));
    				$im = $new_image;
    				imagepng($im, $locDir.substr($net, strpos($net, "/") + 1), 0);
    			}
    		}
    		exit();
    	}
    ?>
    
    <script type="text/javascript">
    	function RepeatingText() {
    		document.write("<?php CheckDrirectory(); ?>");
    		t = setTimeout(function() {RepeatingText()}, 30000);
    	}
    </script>
    
    </head>
    <body onload="RepeatingText()">
    
    <form action="" method="POST" enctype="multipart/form-data">
    	<label name="lblBrowser">Filename :   </label>
        <input type="file" name="fileUpload" id="fileUpload" /><br />
    
        <input type="submit" value="Upload" id="Upload" />
    </form>
    
    </body>
    </html>
    

     

    Please point me out on how to execute it continously.

  8. Great, now I just tried that and the error dissapear also. But now I got this error

     

    Warning: imagecreatefrompng(): Filename cannot be empty in C:\inetpub\wwwroot\ImageReduce\index.php on line 10 Warning: imagepng() expects parameter 1 to be resource, boolean given in C:\inetpub\wwwroot\ImageReduce\index.php on line 11

     

    With some observation file input seems cannot upload exact or more than 2mb image. I've search Mr. Google about it and it gave me data-max-size and max-size attributes but it didn't work, do you know Sir Haku if theres a way around on how to manage the upload of file input?

     

    Thank you in advance.

     

    [Edit]

     

    can - cannot

  9. Sorry I just changed the file input field name into 'fileUploads', but to make it more clearer let me paste the whole code.

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title> Reduce & Resize Images </title>
    
    <?php
    		$im = imagecreatefrompng($_FILES['fileUploads']['tmp_name']);
    		imagepng($im, $_FILES['fileUploads']['name'], 9);
    ?>
    
    </head>
    <body>
    
    <form action="" method="POST" enctype="multipart/form-data">
    	<label name="lblBrowser">Filename :   </label>
        <input type="file" name="fileUploads" id="fileUploads" /><br />
        <input type="submit" name="Upload" value="Upload" />
    </form>
    
    </body>
    </html>
    
  10. Thank you very much sir for the quick response, but I'm afraid thats the only error that I got.

     

    Now I got a new error here is the complete error.

     

    Undefined index: fileUploads in C:\inetpub\wwwroot\ImageReduce\index.php on line 8 Warning: imagecreatefrompng(): Filename cannot be empty in C:\inetpub\wwwroot\ImageReduce\index.php on line 8 Notice: Undefined index: fileUploads in C:\inetpub\wwwroot\ImageReduce\index.php on line 9 Warning: imagepng() expects parameter 1 to be resource, boolean given in C:\inetpub\wwwroot\ImageReduce\index.php on line 9

  11. Guys help here please, this driving me crazy. At first I'm working with this code its running fine, however for some unknown reason

    it keeps telling me this error now "Unidentified Index".

    		$im = imagecreatefrompng($_FILES['fileUpload']['tmp_name']);
    		imagepng($im, $_FILES['fileUpload']['name'], 9);
    

    the above code is what I'm working it is place in <head> tag, I'm just testing the code so thats the only code there.

    why is that Unidentified index then, please help need a quick response.

     

    Thank you in advance.

  12. Hi again guys :happy-04:, alright I'm close to finish my exercise. This time what I want to know is is it possible to continously check a directory for any changes (changes means if the count of files where decrease or increase)? How to put it into a clock or something using PHP.

     

    Or I need to use some sort of javascript?.

     

    Please show me how. Thank you very much in advance. ;D

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.