Jump to content

Tomislav

Members
  • Posts

    20
  • Joined

  • Last visited

Everything posted by Tomislav

  1. It is not working, so i assume that ImageMagick is not installed on server. And that is the reason i have asked for some help here, because I',m not a programmer but I would like to solve that problem myself. So, can someone help me recode it to use PHP GD image functions. Thanks.
  2. Anyone knows how to change the code posted above to work on server wit PHP 5.3. ? elseif (isset($_POST['todoaction']) && $_POST['todoaction'] == 'save') { $original = 'o_'.$_POST['slika']; $path = getenv('DOCUMENT_ROOT').'/images/content/'; $v = exec("convert ".$path.$original." -crop ".$_POST['width']."x".$_POST['height']."+".$_POST['x1']."+".$_POST['y1']." ".$path.$_POST['slika']); list($width, $height) = getimagesize($path.$_POST['slika']); if (isset($_POST['h']) && $_POST['h'] != '') { $v = @exec("convert ".$path.$_POST['slika']." -resize ".$_POST['w']."x".$_POST['h']." ".$path.$_POST['slika']); } else { $v = @exec("convert ".$path.$_POST['slika']." -resize ".$_POST['w']."x225 ".$path.$_POST['slika']); } unset ($slika); }
  3. Thank you a million times. It finally works ! Now, the only thing that is left is cropper tool, it loads and works well, but when cropped picture is saved, it still remains the same picture. But if that can't be solved never mind. Here is cropper.php script : <?php if (isset($_GET['h'])) $max_height = $_GET['h']; else $max_height = 1000; $path = '/images/content/' ?> <script type="text/javascript" src="/javascript/cropper/lib/prototype.js"></script> <script type="text/javascript" src="/javascript/cropper/lib/scriptaculous.js?load=builder,dragdrop"></script> <script type="text/javascript" src="/javascript/cropper/cropper.js"></script> <?php list($cur_width, $cur_height) = getimagesize(getenv('DOCUMENT_ROOT').$path.'o_'.str_replace('m_', '', (str_replace('v_', '', $_GET['slika'])))); $max_width = 480; if ($cur_width > $max_width) { $width = $max_width; $coef = $max_width / $cur_width; $height = round($cur_height * $coef); } else { $width = $cur_width; $coef = 1; $height = $cur_height; } ?> <script type="text/javascript"> <!-- var coef = <?php print $coef; ?>; function onEndCrop( coords, dimensions ) { $( 'x1' ).value = Math.round(coords.x1 / coef); $( 'y1' ).value = Math.round(coords.y1 / coef); $( 'x2' ).value = Math.round(coords.x2 / coef); $( 'y2' ).value = Math.round(coords.y2 / coef); $( 'width' ).value = Math.round(dimensions.width / coef); $( 'height' ).value = Math.round(dimensions.height / coef); } Event.observe( window, 'load', function() { new Cropper.Img( 'fotografija', { min_width: <?php print $_GET['w']; ?>, <?php if (isset($_GET['h'])) { ?> min_height: <?php print $max_height; ?>, <?php if (isset($_GET['q']) && $_GET['q'] != 'proizvodi') { ?> ratioDim: { x: <?= $_GET['w']; ?>, y: <?= $_GET['h']; ?> }, <?php } } ?> displayOnInit: true, onEndCrop: onEndCrop } ); } ); --> </script> <div id="fotka"> <img src="<?= $path.'o_'.str_replace('m_', '', (str_replace('v_', '', $_GET['slika']))); ?>" alt="<?= $_GET['slika']; ?>" id="fotografija" style="width:<?php print $width; ?>px; height:<?php print $height; ?>px; float:none; " /> </div> <?php if ($coef < 1) { ?><p class="bad_alert">Prikaz fotografije je <?php print number_format(($coef * 100),1,',','.'); ?>% njene stvarne veličine.</p><?php } ?> <form id="forma" action="index.php" method="post" enctype="multipart/form-data"> <fieldset> <input type="hidden" name="q" value="<?php print $_GET['q']; ?>" /> <input type="hidden" name="id" value="<?php print $_GET['id']; ?>" /> <input type="hidden" name="slika" value="<?php print $_GET['slika']; ?>" /> <input type="hidden" name="h" value="<?php if(isset($_GET['h'])) print $_GET['h']; ?>" /> <input type="hidden" name="w" value="<?php print $_GET['w']; ?>" /> <label for="cur_width">trenutna širina</label> <input type="text" onkeypress="return disableEnterKey(event)" name="cur_width" id="cur_width" size="4" class="tekst kratki" value="<?php print $cur_width; ?>" /> <label for="cur_height">trenutna visina</label> <input type="text" onkeypress="return disableEnterKey(event)" name="cur_height" id="cur_height" size="4" class="tekst kratki" value="<?php print $cur_height; ?>" /> <label for="width">označena širina</label> <input type="text" onkeypress="return disableEnterKey(event)" name="width" id="width" size="4" class="tekst kratki" /> <label for="height">označena visina</label> <input type="text" onkeypress="return disableEnterKey(event)" name="height" id="height" size="4" class="tekst kratki" /> <label for="x1">x1</label> <input type="text" onkeypress="return disableEnterKey(event)" name="x1" id="x1" size="4" class="tekst kratki" /> <label for="y1">y1</label> <input type="text" onkeypress="return disableEnterKey(event)" name="y1" id="y1" size="4" class="tekst kratki" /> <label for="x2">x2</label> <input type="text" onkeypress="return disableEnterKey(event)" name="x2" id="x2" size="4" class="tekst kratki" /> <label for="y2">y2</label> <input type="text" onkeypress="return disableEnterKey(event)" name="y2" id="y2" size="4" class="tekst kratki" /> <label for="submit"> </label> <input type="hidden" name="todoaction" /> <input type="submit" id="save" name="save" class="btn" style="margin-top:20px;" value="spremi" onclick="document.getElementById('forma').todoaction.value='save';" onkeypress="document.getElementById('forma').todoaction.value='save';" /> </fieldset> </form>
  4. That is already turned on: <?php ini_set('display_errors', 'On'); // Report all PHP errors error_reporting(-1); if (isset($_POST['todoaction']) && $_POST['todoaction'] == 'insert') After upload is finished, a few seconds after i have only my menu on left side, and on right side where form is supposed to be, everything just vanish.
  5. Can you tell me what to remove in code : <?php if (isset($_POST['todoaction']) && $_POST['todoaction'] == 'insert') { if (is_uploaded_file($_FILES['slika']['tmp_name'])) { $path = getenv('DOCUMENT_ROOT').'/images/content/'; $brojac = 1; while (file_exists($path.$brojac.'.jpg')) $brojac = $brojac+1; $slika = $brojac; $filesaved = copy($_FILES['slika']['tmp_name'], $path.'o_'.$slika.'.jpg'); // set original image location $img = $path . 'o_' . $slika . '.jpg'; // set our image canvas $canvas_width = 150; $canvas_height = 500; // get width and height of original image list($img_width, $img_height) = getimagesize($img); $ratio_orig = $img_width / $img_height; if ($canvas_width / $canvas_height > $ratio_orig) { $canvas_width = $canvas_height * $ratio_orig; } else { $canvas_height = $canvas_width / $ratio_orig; } // loading in our original image $original = imagecreatefromjpeg($img); // create a blank canvas $canvas = imagecreatetruecolor($canvas_width, $canvas_height); imagecopyresampled($canvas, $original, 0, 0, 0, 0, $canvas_width, $canvas_height, $img_width, $img_height); if (imagejpeg($canvas, "/home2/smiztita/public_html//images/content/" . $slika . '.jpg', 100)) { return true; } else { return false; } }
  6. this code has finally uploaded resized picture to correct folder with correct name. imagejpeg($canvas, "/home2/smiztita/public_html//images/content/" . $slika.'.jpg', 100) But, seems that my agony still remains. Now when i upload picture via my cms, nothing happens in my form, nothing else is uploaded, and nothing is shown. If i chose not to upload picture, everything is ok. Should I give you the whole code, or are you giving up on me
  7. Here is the latest update to post. I got this warning now: Warning: imagejpeg() [function.imagejpeg]: Unable to open '/images/content/503.jpg' for writing: No such file or directory in/home2/smiztita/public_html/cms/required/osmrtnice.php on line 40 And code is: (imagejpeg($canvas, "/images/content/" . $slika.'.jpg', 100)) Seams that we are close to solving problem.
  8. Hi, jazzman. Had a lot of work, so i have just now tried to solve this thing again. And after some time i have came to this, and that does the job, and saves image in root folder as $slika,jpg. But it is supposed to be saved in root/images/content/ with name as number. I can't find anywhere how to set destination folder. here is code: <?php if (isset($_POST['todoaction']) && $_POST['todoaction'] == 'insert') { if (is_uploaded_file($_FILES['slika']['tmp_name'])) { $path = getenv('DOCUMENT_ROOT').'/images/content/'; $brojac = 1; while (file_exists($path.$brojac.'.jpg')) $brojac = $brojac+1; $slika = $brojac; $filesaved = copy($_FILES['slika']['tmp_name'], $path.'o_'.$slika.'.jpg'); // set original image location $img = $path . 'o_' . $slika . '.jpg'; // set our image canvas $canvas_width = 150; $canvas_height = 500; // get width and height of original image list($img_width, $img_height) = getimagesize($img); $ratio_orig = $img_width / $img_height; if ($canvas_width / $canvas_height > $ratio_orig) { $canvas_width = $canvas_height * $ratio_orig; } else { $canvas_height = $canvas_width / $ratio_orig; } // loading in our original image $original = imagecreatefromjpeg($img); // create a blank canvas $canvas = imagecreatetruecolor($canvas_width, $canvas_height); imagecopyresampled($canvas, $original, 0, 0, 0, 0, $canvas_width, $canvas_height, $img_width, $img_height); if (imagejpeg($canvas, '$slika.jpg', 100)) { return true; } else { return false; } }
  9. Hi, still not working. Image is uploaded on correct folder on server with prefix o_ And it is not resized, and not visible in my cms webpage. After removing prefix o_ image is then visible but not resized, and crop function is not working, probably not supported after upgrade PHP server. So what is to solve is resizing image and after that saving image without prefix o_, only number of picture. If anyone have time to take a look for solution I would be very happy. THX
  10. tried code below, still not working, going to sleep maybe tomorrow will be better day $path = getenv('DOCUMENT_ROOT').'/images/content/'; $brojac = 1; while (file_exists($path.$brojac.'.jpg')) $brojac = $brojac+1; $slika = $brojac; $filesaved = copy($_FILES['slika']['tmp_name'], $path.'o_'.$slika.'.jpg'); // The file $filename = $path.'o_'.$slika.'.jpg''; // Set a maximum height and width $width = 150; $height = 500; // Content type header('Content-type: image/jpeg'); // Get new dimensions list($width_orig, $height_orig) = getimagesize($filename); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } // Resample $path.$slika.'.jpg' = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); imagecopyresampled($path.$slika.'.jpg', $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output imagejpeg($image_p, null, 100);
  11. vinny, i think that you have found a problem. this function is not working. everything is done before that, and than when it should be resized and renamed, nothing happens. can you tell me witch gd function will do the job , because i want to have possibility in CMS to crop picture, and than that cropped image is displayed in size 150 width, and height is proportionally to resize %. This is size for all images displayed on page, 150 width. here is link to see http://www.osmrtnica.net/posljednji_pozdravi/str/3/ Thanks a lot.
  12. No, image is uploaded on the server, but then it is supposed to be copied for editing ( crop, resize). I have tried with move_uploaded_file() istead copy function, but it is the same. Is there other way to do the same thing?
  13. I have done that now and no errors are displayed. But i have noticed now that picture is saved in correct folder and named o_503.jpg The letter o stands for original picture, and now it should be copied, resized and named 503.jpg without letter o in front.
  14. i have put this in first line <?php // Report all PHP errors error_reporting(-1); and where do I see errors now?
  15. Hi all. I have a web page where user can upload pictures for publishing obituaries. everything worked fine until upgrading server to PHP 5.3.27 Now new pictures are not visible even in my CMS backoffice. Photos uploaded before upgrade are still visible. I can see that pictures are uploaded in folder /images/content/ anyone have some idea? below is code for uploading pictures. Thanks in advance . { if (is_uploaded_file($_FILES['slika']['tmp_name'])) { $path = getenv('DOCUMENT_ROOT').'/images/content/'; $brojac = 1; while (file_exists($path.$brojac.'.jpg')) $brojac = $brojac+1; $slika = $brojac; $filesaved = copy($_FILES['slika']['tmp_name'], $path.'o_'.$slika.'.jpg'); list($width, $height) = getimagesize($path.'o_'.$slika.'.jpg'); $v = exec("convert ".$path.'o_'.$slika.".jpg -resize 150x500 ".$path.$slika.'.jpg'); $v = exec("convert ".$path.$slika.".jpg -crop 150x200+0+0 ".$path.$slika.'.jpg'); }
  16. Almost solved. Now i got this massage in field where was date written : <br /><b>Notice</b>: Use of undefined constant date - assumed 'date' in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /><br /><b>Warning</b>: date() expects parameter 2 to be long, string given in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br />
  17. I have already done that, here is my php.ini : [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = Europe/Zagreb
  18. Hi all ! I need some help. I'm not a programer but I would like to solve problem with my website by myself. After upgrading PHP on server where is my web page ( www.osmrtnica.net ), i'm getting a lot of errors in my CMS. I hope that someone will have a few minutes to give a look. I have bolded text in code at line 380. And i know that is a lot of text, but what can i do. Thanks in advance. here are the errors: <br /><b>Warning</b>: main() [<a href='function.main'>function.main</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /><br /><b>Notice</b>: Use of undefined constant date - assumed 'date' in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /><br /><b>Warning</b>: strtotime() [<a href='function.strtotime'>function.strtotime</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /><br /><b>Warning</b>: strtotime() [<a href='function.strtotime'>function.strtotime</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /><br /><b>Warning</b>: date() [<a href='function.date'>function.date</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /><br /><b>Warning</b>: date() expects parameter 2 to be long, string given in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /> And here is a part of code where error ocurs: <div class="h3" style="height:1px;"> </div> <div style="width:450px; float:left; "> <label for="odobreno">odobreno:</label> <input type="checkbox" class="chk" name="odobreno" id="odobreno" value="1"<?php if ($row['odobreno'] == 't') { ?> checked="checked"<?php } ?> /> <label for="datum">datum:</label> <input type="text" name="datum" id="datum" class="tekst srednji" value="<?php if ($row['datum'] != '') print date('d.m.Y', date.strtotime($row['datum'])); else print date('d.m.Y'); ?>" /> <script type="text/javascript"> <!-- $(document).ready(function(){ $('#datum').datepicker({ mandatory: true, navigationAsDateFormat: true, prevText: '<M', nextText: 'M>', changeMonth: false, monthNames: ['siječanj ','veljača ','ožujak ','travanj ','svibanj ','lipanj ', 'srpanj ','kolovoz ','rujan ', 'listopad ','studeni ','prosinac '], monthNamesShort: ['sij','velj','ožu','tra','svi','lip','srp','kol','ruj','lis','stu','pro'], changeYear: false, weekHeader: '', showWeeks: true, dayNames: ['nedjelja', 'ponedjeljak', 'utorak', 'srijeda', 'četvrtak', 'petak', 'subota'], dayNamesShort: ['ned', 'pon', 'uto', 'srij', 'čet', 'pet', 'sub'], dayNamesMin: ['N', 'P', 'U', 'S','Č', 'P', 'S'], showOtherMonths: true, numberOfMonths: 1, defaultDate: Date(<?= date('Y, m, d', strtotime($row['datum'])); ?>), // default date - Date(yyyy, mm - 1, dd), dateFormat: 'dd.mm.yy', showWeeks: true, firstDay: 1, changeFirstDay: false, closeText: 'X', prevText: '<', nextText: '>', currentText: '' }); }); //--> </script>
×
×
  • 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.