Я разрабатываю веб-сайт, который должен позволять пользователю нажимать кнопку ПЕЧАТЬ для печати определенных c изображений, предлагаемых на сайте (формат .jpg).
Затем пользователю необходимо выбрать размеры печати (пропорции будут фиксированными, чтобы соответствовать изображению, , которое будет варьироваться ), до максимального размера 40 дюймов в либо измерение.
ЭТО ЖЕСТКАЯ ЧАСТЬ: если изображение больше буквенного формата (8,5 x 11), то изображение должно быть напечатано на нескольких страницах , чтобы добавить к выбранный пользователем размер.
ДЛЯ ПОЛУЧЕНИЯ ФАНКИ (ДОПОЛНИТЕЛЬНО): для печати на бумаге должно быть установлено минимально возможное значение для сохранения на бумаге.
<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
computer image upload:
<input name="uploadedfile" type="file" />
Web image upload (URL):
<input type="text" name="url" />
<input type="submit" value="Upload File" name="upload"/>
</form>
<?php
session_start();
// SETTINGS
$thumbwidth = 100;
$deleteDays = 1;
$size['letter']['width'] = 21.59;
$size['letter']['height'] = 27.94;
$size['a4']['width'] = 21.0;
$size['a4']['height'] = 29.7;
// A4 210 x 297
// Letter 215.9 x 279.4
// 1 inch = 2.54 cm
$inch = 2.54;
$border = 2.54;
function make_thumb($src,$dest,$desired_width) {
$arr = getimagesize($src);
/* read the source image */
switch ($arr['mime']) {
case 'image/jpeg' : $source_image = imagecreatefromjpeg($src); break;
case 'image/png' : $source_image = imagecreatefrompng($src); break;
case 'image/gif' : $source_image = imagecreatefromgif($src); break;
default: $ext = '';
}
$width = imagesx($source_image);
$height = imagesy($source_image);
/* find the "desired height" of this thumbnail, relative to the desired width */
$desired_height = floor($height*($desired_width/$width));
/* create a new, "virtual" image */
$virtual_image = imagecreatetruecolor($desired_width,$desired_height);
/* copy source image at a resized size */ imagecopyresized($virtual_image,$source_image,0,0,0,0,$desired_width,$desired_height,$width,$height);
switch ($arr['mime']) {
case 'image/jpeg' : imagejpeg($virtual_image,$dest); break;
case 'image/png' : imagepng($virtual_image,$dest); break;
case 'image/gif' : imagegif($virtual_image,$dest); break;
default: $ext = '';
}
/* create the physical thumbnail image to its destination */
imagejpeg($virtual_image,$dest);
}
if(isset($_POST['upload']) && $_POST['url']=='') {
$target_path = "images/";
$large = $target_path . date('YmdHis').'_'.session_id().'.'.substr(basename( $_FILES['uploadedfile']['name']),-3);
$thumb = $target_path . date('YmdHis').'_'.session_id().'_thumb.'.substr(basename( $_FILES['uploadedfile']['name']),-3);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $large)) {
make_thumb($large,$thumb,$thumbwidth);
}
}
elseif (strlen($_POST['url'])>0) {
$arr = getimagesize($_POST['url']);
$ext = '';
switch ($arr['mime']) {
case 'image/jpeg' : $ext = 'jpg'; break;
case 'image/png' : $ext = 'png'; break;
case 'image/gif' : $ext = 'gif'; break;
default: $ext = '';
}
if ($ext != '') {
$file = 'images/'.date('YmdHis').'_'.session_id();
$fh = fopen($file.'.'.$ext,'w+');
$img = file_get_contents($_POST['url']);
fwrite($fh,$img);
fclose($fh);
make_thumb($file.'.'.$ext,$file.'_thumb.'.$ext,$thumbwidth);
}
}
?>
if (ratio == 'yes') {
document.getElementById('imgheight').readOnly = true;
<?php
if (isset($_GET['print'])) {
$arr = getimagesize('images/'.str_replace('_thumb','',$_GET['print']));
echo 'x = '.$arr[0].';';
echo 'y = '.$arr[1].';';
}
?>
width = document.getElementById('imgwidth').value;
one = x/width;
height = y/one;
if (height > 0) {
document.getElementById('imgheight').value = height.toFixed(2);
}
}
else {
document.getElementById('imgheight').readOnly = false;
}
}
function calc() {
if(document.getElementById('imgheight').readOnly == true) {
<?php
if (isset($_GET['print'])) {
$arr = getimagesize('images/'.str_replace('_thumb','',$_GET['print']));
echo 'x = '.$arr[0].';';
echo 'y = '.$arr[1].';';
}
?>
width = document.getElementById('imgwidth').value;
one = x/width;
height = y/one;
if (height > 0) {
document.getElementById('imgheight').value = height.toFixed(2);
}
}
}
</script>
![image](images/'.$file.')