У меня есть страница, которая используется только для печати, а некоторые изображения на ней загружаются через сценарий, который у меня есть. Кажется, всегда уменьшает изображение до 72 точек на дюйм, независимо от того, что я установил imagejpeg()
и imagepng()
для качества.Загрузка PHP по умолчанию равна 72 dpi, мне нужно 300 dpi
Я использовал свой собственный скрипт, и этот на мерзавец ступице
https://github.com/maxim/smart_resize_image
Я надеялся на мало указаний на сохранение точек на дюйм в оригинальном 300dpi.
Вот мой собственный личный сценарий
if (!empty($_FILES['image']['name'])) //checking if file upload box contains a value
{
$saveDirectory = 'pics/'; //name of folder to upload to
$tempName = $_FILES['image']['tmp_name']; //getting the temp name on server
$fileName1 = $_FILES['image']['name']; //getting file name on users computer
$count = 1;
do{
$location = $saveDirectory . $_GET['section'] . $count . $fileName1;
$count++;
}while(is_file($location));
if (move_uploaded_file($tempName, $location)) //Moves the temp file on server
{ //to directory with real name
$image = $location;
// Get new sizes
list($width, $height, $type) = getimagesize($image); //gets information about new server image
$framewidth = 932;
$frameheight = 354;
$realwidth = $width; //setting original width and height
$realheight = $height;
// Load
$file1new = imagecreatetruecolor($framewidth, $frameheight); //creates all black image with target w/h
if($type == 2){
$source = imagecreatefromjpeg($image);
imagecopyresampled($file1new, $source , 0, 0, 0, 0, $framewidth, $frameheight, $realwidth, $realheight);
}
elseif($type == 3){
$source = imagecreatefrompng($image);
imagecopyresampled($file1new, $source , 0, 0, 0, 0, $framewidth, $frameheight, $realwidth, $realheight);
}
else{
echo "Wrong file type";
}
if($type == 2){
//creates jpeg image from file1new for file1 (also retains quality)
imagejpeg($file1new, $image,100);
//frees space
imagedestroy($file1new);
}
elseif($type == 3){
//creates png image from file1new for file1 (also retains quality)
imagepng($file1new, $image,10);
//frees space
imagedestroy($file1new);
}
else{
echo "Wrong file type";
}
}
else
{
echo '<h1> There was an error while uploading the file.</h1>';
}
}
}
Edit: Даже если дюйм не ответ, как я вижу JPGs в конкретных не сохраняют эту информацию. Мне нужен способ сохранить эти изображения очень четкими и четкими.
Есть ли у ImageMagick это поведение? Можете попробовать и попробовать. –
Я еще ничего не пробовал с маской изображения. Сейчас я изучаю это. (Я никогда не использовал его раньше). –
Я искал GD для воображения, это просто потрясающе, и вы можете найти так много примеров, чтобы манипулировать изображением, о которых вы никогда не знали, было так просто ... Конечно, если он не может делать то, что вы описали, он все равно будет сосать;) –