{"action":"created","issue":{"url":"https://api.github.com/repos/literallycanvas/literallycanvas/issues/271","labels_url":"https://api.github.com/repos/literallycanvas/literallycanvas/issues/271/labels{/name}","comments_url":"https://api.github.com/repos/literallycanvas/literallycanvas/issues/271/comments","events_url":"https://api.github.com/repos/literallycanvas/literallycanvas/issues/271/events","html_url":"https://github.com/literallycanvas/literallycanvas/issues/271","id":60665266,"number":271,"title":"Cannot save when add big image as background","user":{"login":"nobutsta","id":1971066,"avatar_url":"https://avatars.githubusercontent.com/u/1971066?v=3","gravatar_id":"","url":"https://api.github.com/users/nobutsta","html_url":"https://github.com/nobutsta","followers_url":"https://api.github.com/users/nobutsta/followers","following_url":"https://api.github.com/users/nobutsta/following{/other_user}","gists_url":"https://api.github.com/users/nobutsta/gists{/gist_id}","starred_url":"https://api.github.com/users/nobutsta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nobutsta/subscriptions","organizations_url":"https://api.github.com/users/nobutsta/orgs","repos_url":"https://api.github.com/users/nobutsta/repos","events_url":"https://api.github.com/users/nobutsta/events{/privacy}","received_events_url":"https://api.github.com/users/nobutsta/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-03-11T14:19:57Z","updated_at":"2015-08-05T11:28:57Z","closed_at":"2015-07-31T18:11:30Z","body":"Hello,\r\nI tried set up big image from my camera as a background so we can draw a cartoon on it. But finally I can save it into file for some reason. It seems like those encoded image cannot send through. This is my code before sending.\r\n\r\n      $(document).ready(function() {\r\n        // disable scrolling on touch devices so we can actually draw\r\n        $(document).bind('touchmove', function(e) {\r\n          if (e.target === document.documentElement) {\r\n            return e.preventDefault();\r\n          }\r\n        });\r\n\r\n        LC.setDefaultImageURLPrefix('icons/');\t\t\r\n\r\n        var backgroundImage = new Image();\r\n        backgroundImage.src = '<?=urldecode($_GET[file]);?>';\r\n\r\n\t\tvar logo = new Image();\r\n        logo.src = 'images/logo153x60.png'\r\n\r\n        // the only LC-specific thing we have to do\r\n        var containerOne = document.getElementsByClassName('workSpace')[0];\r\n        var lc = LC.init(containerOne, {\r\n\t\t\timageSize: {width: 1200, height: 800},\r\n          backgroundShapes: [\r\n            LC.createShape('Image', {image: backgroundImage, x: 0, y: 0, image: backgroundImage, scale: 1}),//position of background\r\n\t\t\tLC.createShape('Image', {image: backgroundImage, x: 10, y: 690, image: logo, scale: 1})//logo\r\n          ]\r\n        });\r\n        window.demoLC = lc;\r\n        lc.loadSnapshotJSON(localStorage.getItem('drawing'));//load previous drawing\r\n\r\n        lc.on('drawingChange', function() {\r\n          localStorage.setItem('drawing', lc.getSnapshotJSON());\r\n        });\r\n\r\n         //lc.setPan(100, 100);\r\n\t\t lc.setImageSize(1200, 800);//set the reset image size\r\n\t\t//var exportIMG=lc.getImage({rect: {x: 0, y: 0, width: 800, height: 600},scale: 1}).toDataURL();\r\n        \r\n\t\t$('[data-action=exportIMG]').click(function(e) {\r\n\t\t  e.preventDefault();\r\n\r\n\t\t  $('.export_btn').html('Saving...')\r\n\t\t  // this is all standard Imgur API; only LC-specific thing is the image\r\n\t\t  // data argument;\r\n\t\t  $.ajax({\r\n\t\t\turl: 'print.php',\r\n\t\t\ttype: 'POST',\r\n\t\t\tdata: {\r\n\t\t\t  // convert the image data to base64\r\n\t\t\t\tfilename:'<?=$_GET[file]?>',\r\n\t\t\t\timage:  lc.canvasForExport().toDataURL().split(',')[1]\r\n\t\t\t},\r\n\t\t\tsuccess: function(data) {\r\n\t\t\t\tif(jQuery.trim(data) === \"ok\"){\r\n\t\t\t\t\t$('#saveModal').modal('show'); \r\n\t\t\t\t\t$(\".modal-title\").html(\"Luckily\");\r\n\t\t\t\t\t$(\".modal-body\").html(\"<span class=\\\"text-success\\\">Photo saved</span>\");\r\n\t\t\t\t\t//$(\".modal-body\").html(data);\r\n\t\t\t\t  }else{\r\n\t\t\t\t\t$('#saveModal').modal('show'); \r\n\t\t\t\t\t$(\".modal-title\").html(\"Error\");\r\n\t\t\t\t\t//$(\".modal-body\").html(\"<span class=\\\"text-danger\\\">Cannot save</span>\");\r\n\t\t\t\t\t$(\".modal-body\").html(data);\r\n\t\t\t\t\t\r\n\t\t\t\t  }//if\r\n\t\t\t\t  //setTimeout(function() { $('#saveModal').modal('hide'); }, 2000);//hide modal after 2 sec\r\n\t\t\t},//success\r\n\t\t  });\r\n\t\t  return false;\r\n\t\t});//click(function(e)\r\n      });\r\n\r\nI am searching for couple of days for this but no luck. Please point me out."},"comment":{"url":"https://api.github.com/repos/literallycanvas/literallycanvas/issues/comments/127962381","html_url":"https://github.com/literallycanvas/literallycanvas/issues/271#issuecomment-127962381","issue_url":"https://api.github.com/repos/literallycanvas/literallycanvas/issues/271","id":127962381,"user":{"login":"nobutsta","id":1971066,"avatar_url":"https://avatars.githubusercontent.com/u/1971066?v=3","gravatar_id":"","url":"https://api.github.com/users/nobutsta","html_url":"https://github.com/nobutsta","followers_url":"https://api.github.com/users/nobutsta/followers","following_url":"https://api.github.com/users/nobutsta/following{/other_user}","gists_url":"https://api.github.com/users/nobutsta/gists{/gist_id}","starred_url":"https://api.github.com/users/nobutsta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nobutsta/subscriptions","organizations_url":"https://api.github.com/users/nobutsta/orgs","repos_url":"https://api.github.com/users/nobutsta/repos","events_url":"https://api.github.com/users/nobutsta/events{/privacy}","received_events_url":"https://api.github.com/users/nobutsta/received_events","type":"User","site_admin":false},"created_at":"2015-08-05T11:28:56Z","updated_at":"2015-08-05T11:28:56Z","body":"This is `print.php` script.\r\n\r\n<?php\r\nheader('Content-Type: image/jpeg');\r\nini_set('memory_limit', '32M');\r\n$data=$_POST['image'];\r\nif(!$_POST['filename']){\r\n\texit(\"error\");\r\n}\r\nlist($dir,$folder,$file)=explode(\"/\",$_POST['filename']);\r\n$ext=strtolower(pathinfo($_POST['filename'], PATHINFO_EXTENSION));\r\n\r\n$file=basename($file,\".\".$ext);\r\n//$data = substr($data, strpos($data, \",\")+1);\r\n$data = base64_decode($data);\r\n\r\n$imgRes = imagecreatefromstring($data);\r\nif($imgRes !== false && imagejpeg($imgRes, $file,\"100\") === true)\r\n\tif(!is_dir($dir.'/'.$folder.'/new/')){\r\n\t\tmkdir($dir.'/'.$folder.'/new/',0777);\r\n\t}\r\n\t$photo=$dir.'/'.$folder.'/new/'.$file.'-'.time().\".\".$ext;//print directly\r\n\tif(file_put_contents($photo, $data)){\t\t\r\n\t\t//echo \"<script type=\\\"text/javascript\\\">window.open(\\\"print_out.php?file=$photo\\\", \\\"Printing...\\\", \\\"width=1, height=1\\\");</script>\";//open new window and print\r\n\t\t//echo \"ok\";\r\n\t}else{\r\n\t\techo \"error\";\r\n\t}\r\nimagedestroy($imgRes);\r\n?>"}}