Photo with landscape orientation like first in the gallery - laravel

My users can add photos to their gallery. I want that like a first will display photo with landscape orientation or the widest (it will be better). I don't care about sort. I wrote only about first photo in gallery.

try intervention/image package
for orientation use this code
// import the Intervention Image Manager Class
use Intervention\Image\ImageManagerStatic as Image;
$img = Image::make('foo.jpg')->orientate();

Related

Flutter use InteractiveViewer to crop an image

I'd like to use InteractiveViewer in order to implement my own image crop.
Steps:
The user pans and scales an image, using InteractiveViewer
The user clicks a button
Get the "viewable" part of the InteractiveViewer content (bounding box)
Using this library, crop the image
Resize the cropped image (scale down), maybe compress it, and upload to my server
I fail to understand step 3: getting the "viewable" part of the InteractiveViewer content

I'm trying to clip an image overlay in Google Maps API

I'm trying to clip an image overlay in Google Maps API, however without success. I can clip a HTML image successfully and overlay it on a Google MAP by using the CSS clip property and z-index property, however that's no use, as the image does not adjust to the Google map zoom and movements. i.e. the image is not bound to the Google MAP object in any way, doesn't respond to map changes.
If I assign the Google Map overlay to the cropped image source, it simply uses the original un-cropped source and not the cropped page image element. That's just how the image.src property works.
I successfully added an image overlay for Google MAPS, but there does not seem to be any clipping or cropping function for them. There is text on the image that I don't want to display for this application, but I don't want to crop the original source file image, as it's used for multiple display purposes.
historicalOverlay = new google.maps.GroundOverlay(imageurl,imageBounds);
historicalOverlay.setMap(map);
I need imageurl to point to a clipped version in memory or something like that or the clipped form image element, but not its un-clipped source image. Any ideas ?
The GroundOverlay class in Google Maps javascript API V3 does not provide any support for in-browser clipping/cropping of the image before display.
Because we needed that capability, plus some others like image rotation and non-rectangular images, we wrote a GroundOverlayEX javascript class that supports everything that the Google Earth version of GroundOverlay supports, including browser-side clipping/cropping of the image to-be-displayed.
The javascript class is open-source on Github at: https://github.com/azmikemm/GroundOverlayEX. There is API documentation as well (documentation.txt). All images shown by the GroundOverlayEX class are integral to the map, and will drag with the map, and zoom with the map.
A working functional example of the class in-action (with some clipped/ cropped images) is at: https://sites.google.com/site/issearthatnight/
If you turn off the VIIRS checkbox, and set the transparency down to midway, you'll see the images pretty plainly, and see that some are cropped (all are stored in NASA's servers as rectangles, so images that are square-ish or look like slices have been cropped by the GroundOverlayEX class).

How to display category image after resize in Magento?

I am displaying any size image to fit in a 175x175 frame so it loses its original shape on the category page.
I want to display category image after resize that like product image is resized and displayed.
How can I do this in Magento 1.7.0.2?
You will have to maually resize using Magento's image libs, herwes an example (http://blog.chapagain.com.np/magento-resize-image/):
// actual path of image
$imageUrl = Mage::getBaseDir('media').DS."myimage".DS.$post->getThumbnail();
// path of the resized image to be saved
// here, the resized image is saved in media/resized folder
$imageResized = Mage::getBaseDir('media').DS."myimage".DS."resized".DS.$post->getThumbnail();
// resize image only if the image file exists and the resized image file doesn't exist
// the image is resized proportionally with the width/height 135px
if (!file_exists($imageResized)&&file_exists($_imageUrl)) :
$imageObj = new Varien_Image($_imageUrl);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(TRUE);
$imageObj->keepFrame(FALSE);
$imageObj->resize(135, 135);
$imageObj->save($imageResized);
endif;
$newImageUrl = Mage::getBaseUrl('media')."catalog/category/resized/".$imageName;
If you take a look at Varien_Image you will see there's a few different methods to help resize images. Unfortunately there's no helper to use as there is for product images, although it wouldn't be difficult to make a helper to do this.

Proper way to use images in NSMenuItem?

I've put some images next to NSMenuItems using the image option in Interface Builder. The custom image is a simple PNG. I was hoping the system would automatically alter the color of the image during mouse over like it does with stock images. It does not. What am i doing wrong?
Here's a pic of a stock image vs my custom one:
In code, call [menuItem.offStateImage setTemplate:YES]

magento: Resize image during upload to desired dimensions

I want to resize product images before upload them by using values through text boxes.
eg:
user browse image and then give width(px) in one text and height(px) in another textbox click on apply and now this size is apply on image.
then user upload image.
can any one tell me or guide me to resource so i can get this functionality.
i already added both text box with button on product image upload grid.
What is the point? Magento spares you from any of that fooling around with images. You upload them in whatever size you want hen it creates and caches the sizes it needs on the fly. What your trying to achieve is a leap backwards.
Please use this code to resize your image
$imageUrl = "http://localhost/";
$imageResized = Mage::getBaseDir('media').DS."catalog/category/resized";
$imageObj = new Varien_Image($imageUrl);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(TRUE);
$imageObj->keepFrame(false);
$imageObj->keepTransparency(True);
$imageObj->setImageBackgroundColor(false);
$imageObj->backgroundColor(false);
$imageObj->quality(100);
$imageObj->setWatermarkImageOpacity(0);
$imageObj->resize(120, 120);
$imageObj->save($imageResized);
I think you have to look at this controller.
Mage_Adminhtml_Catalog_Product_GalleryController
You will need to rewrite this controller. Some how make the width and height values arrive to the action. And than apply re-sizing to the image.
HTH

Resources