televisor smart saber que para mucha menos mas luz gasta energia enchufado electrodomesticos electricidad electrica consumen consume computador como aparatos aparato apagados php image mobile upload

php - smart - que aparatos consumen mas energia electrica



Bueno, esto es nuevo. No es posible cargar fotos desde teléfonos inteligentes? (2)

Es posible que desee buscar en la función exif_read_data () y ver el valor [''Orientation''] que se devuelve en la matriz. Normalmente, un teléfono o cámara que tiene sensores de orientación almacenan la imagen en una u otra orientación, y luego agregan indicadores de orientación adecuados a los datos exif en la imagen. Depende del visor de imágenes o del procesador de imágenes determinar si se debe rotar la imagen sin formato antes de mostrar o procesar la imagen.

Hay algunos buenos ejemplos en los comentarios de esa página.

Función construida a partir de uno de los ejemplos en esa página:

<?php function getOrientedImage($imagePath){ $image = imagecreatefromstring(file_get_contents($imagePath)); $exif = exif_read_data($imagePath); if(!empty($exif[''Orientation''])) { switch($exif[''Orientation'']) { case 8: $image = imagerotate($image,90,0); break; case 3: $image = imagerotate($image,180,0); break; case 6: $image = imagerotate($image,-90,0); break; } } return $image; } ?>

Además, con respecto al tiempo de carga, si el dispositivo está utilizando torres de telefonía móvil para transmitir los datos, las velocidades de carga probablemente sean una fracción de las velocidades de descarga. Por razones de comparación, la mayoría de las aplicaciones de redes sociales cambian el tamaño de la imagen antes de cargarla, mientras que su página web probablemente no lo haga. Dado que los teléfonos toman fotos de 8 megapíxeles o más, eso se suma a una gran cantidad de datos.

Así que estoy creando un sitio web receptivo que tiene la opción de subir imágenes a la página. La secuencia de comandos php básicamente cambia el tamaño de la imagen y almacena una ruta de archivo de pulgar en la base de datos. La imagen original y la imagen del pulgar también se almacenan en la carpeta del sitio web. Estoy usando la biblioteca de GD.

De todos modos, solo estaba haciendo una prueba para subir una foto de mi iphone al sitio web. Sube la imagen. Sin embargo, hay dos problemas con esto.

  1. Lleva mucho tiempo cargar una foto.
  2. La foto se orienta hacia los lados después de que se haya terminado de cargar. Si la foto fue retrato, se cargará como paisaje. Extraño.

¿Alguien puede ayudarme con estos dos problemas?

CÓDIGO DE ACTUALIZACIÓN

if (isset($_FILES[''image''])) { if (empty($_FILES[''image''][''name''])) { ?><div class="add-errors">Please choose an image!</div><?php } else { function getOrientedImage($imagePath){ $image = imagecreatefromstring(file_get_contents($imagePath)); $exif = exif_read_data($imagePath); if(!empty($exif[''Orientation''])) { switch($exif[''Orientation'']) { case 8: $image = imagerotate($image,90,0); break; case 3: $image = imagerotate($image,180,0); break; case 6: $image = imagerotate($image,-90,0); break; } } return $image; } $name = $_FILES[''image''][''name'']; $temp = $_FILES[''image''][''tmp_name'']; $type = $_FILES[''image''][''type'']; $size = $_FILES[''image''][''size'']; $ext = strtolower(end(explode(''.'', $name))); $size2 = getimagesize($temp); $width = $size2[0]; $height = $size2[1]; $upload = md5( rand( 0, 1000 ) . rand( 0, 1000 ) . rand( 0, 1000 ) . rand( 0, 1000 )); // Restrictions for uploading $maxwidth = 6000; $maxheight = 6000; $allowed = array(''image/jpeg'', ''image/jpg'', ''image/png'', ''image/gif''); // Recognizing the extension switch($type){ // Image/Jpeg case ''image/jpeg'': $ext= ''.jpeg''; break; // Image/Jpg case ''image/jpg'': $ext= ''.jpg''; break; // Image/png case ''image/png'': $ext= ''.png''; break; // Image/gif case ''image/gif'': $ext= ''.gif''; break; } // upload variables $path = $userDir . $upload . $ext; $thumb_path = $userDir . ''thumb_'' . $upload . $ext; // check if extension is allowed. if (in_array($type, $allowed)) { // Checking if the resolution is FULLHD or under this resolution. if ($width <= $maxwidth && $height <= $maxheight) { if ($size <= 5242880) { // check the shape of the image if ($width == $height) {$shape = 1;} if ($width > $height) {$shape = 2;} if ($width < $height) {$shape = 2;} //Adjusting the resize script on shape. switch($shape) { // Code to resize a square image. case 1: $newwidth = 690; $newheight = 690; break; // Code to resize a tall image case 2: $newwidth = 690; $ratio = $newwidth / $width; $newheight = round($height * $ratio); break; } // Resizing according to extension. switch ($type) { // Image/Jpeg case ''image/jpeg''; $img = getOrientedImage($temp); $thumb = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagejpeg($thumb, $thumb_path); break; // Image/Jpg case ''image/jpg''; $img = getOrientedImage($temp); $thumb = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagejpeg($thumb, $thumb_path); break; // Image/png case ''image/png''; $img = getOrientedImage($temp); $thumb = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagepng($thumb, $thumb_path); break; // Image/gif case ''image/gif''; $img = getOrientedImage($temp); $thumb = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagegif($thumb, $thumb_path); break; } // Move the original file aswell. move_uploaded_file($temp, $path); } else { ?><div class="add-errors">Your image size is too big!</div><?php } } else { ?><div class="add-errors">Your image resolution exceeds the limit!</div><?php } } else { ?><div class="add-errors">Your have uploaded a forbidden extension!</div><?php } } }


1) No estoy seguro de si hay algo que pueda hacer al respecto, cargue la imagen que seleccionó el usuario. En una aplicación, posiblemente reduciría la imagen antes de la transmisión.

2) Lo que sea que esté mirando para ver la foto (o generar miniaturas) probablemente no respete la bandera de orientación en la foto.