Way to get un-cropped thumbnail images? - google-drive-api

Can anyone advise if / how to get un-cropped thumbnail images of files in drive?
Thumbnails in the Recent files component appear to be un-cropped (if you use browser inspector), whereas thumbnails in the component below it are below are cropped. While you can change the size of the thumbnail in its url query params, this doesnt solve the cropping problem.
Im building a redesigned frontend - using css grid for a more irregular aesthetic - as a learning project. To do this, Id need to get un-cropped images - to, for example, show documents as vertical rectangles, not the standard square cropped thumbnail. Id appreciate it if you have any ideas on this. Thanks!

Related

Twitter Bootstrap Image Gallery - creating automatic thumbnails

I thought the thumbnail component of Bootstrap automatically took an image, and cut out a specific size thumbnail to slap on the site. Either I'm using this feature wrong or this is completely false. Everytime I create class="thumbnail", I just get a slightly smaller version of the photo.
As a photographer, my photos are huge, and the "thumbnails" are taking up half the page! Certainly I could resize everything in Photoshop to a 200X200px size and upload these as thumbnails, but I feel like there must be a beter way of doing this.
I tried in the html itself just putting width="200" and height="200" after img src, but the problem here is that instead of cutting a 200X200 square out of the image, the image was scaled down proportionally using one dimension. I.e., the image fits in a 200X200 square, but rather than filling up the entire square (since that's not the original proportions), it fills up a 200X100 type area.
Can anyone help?
Bootstrap won't resize your images. It is a CSS framework, it can only add styles to your web page but you can't use it to do any backend work, like thumbnails creation. Setting the dimensions in the HTML img tag doesn't resize your image neither, it is still the same image that is sent to the browser. So in order to boost your website performance, you need to think of another solution, you don't want to send huge images through the network if you're only gonna show them with thumbnail size.
What kind of website are you running?
For example, Wordpress automatically handles the thumbnails creation when you upload files through the Media Manager. I'm pretty sure most of the CMS have this functionnality.
If you have a PHP website without a CMS, you could try using a library such as phpthumb, that would require some coding though.
If you have a static HTML website, then you have no other choice but to resize the images manually in Photoshop.
By the way, do you optimize your images too? (compression with tools such as tinypng or jpeg-optimizer
I've got a little code to generate thumb:
public function generateThumb($pathToImage, $pathToThumb, $extension, $maxDim)
{
//Create a new image according to "MimeType"
switch($extension){
case "gif":
$img = imagecreatefromgif("{$pathToImage}");
break;
case "jpeg":
$img = imagecreatefromjpeg("{$pathToImage}");
break;
case "png":
$img = imagecreatefrompng("{$pathToImage}");
break;
}
// load image and get image size
$width = imagesx($img);
$height = imagesy($img);
// calculate thumbnail size, vertical and horizontal orientation
$new_width = ($width > $height) ? $maxDim : floor($width * ( $maxDim / $height ));
$new_height = ($height > $width) ? $maxDim : floor($height * ( $maxDim / $width ));
// create a new temporary image
$tmp_img = imagecreatetruecolor($new_width, $new_height);
// copy and resize old image into new image
imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// save thumbnail into a file
imagejpeg($tmp_img, "{$pathToThumb}");
}
I'm sorry, but I can't remember where I found the original script (On SO and other website).
Using that you can generate a thumb each time you add a new image and then use this thumb in your thumbnail preview.
Nop, the Bootstrap will not resize files for You.
Even if You're the only user of the site u can make a file-upload form for yourself. Take a look at Paperclip - it's awesome. And do not forget to protect this form to disallow network users upload some ugly images on your site
Bookstrap is not for resizing api. You can use many of the Image Compression apps that are available.
I would recommend http://shrinkjpeg.com since it does not upload the images to server and compresses them locally in browser.

SWF with multiple "stages"

Is it possible to have a single SWF file with multiple "stages" appearing at different parts of the page and sharing data?
What I'm trying to do requires sharing big amount of data (byteArrays of image data) that cannot be shared through LocalConnections or via JS (very slow) so I'm trying to avoid the "sharing" part and somehow do it in a single SWF. Problem is, those images need to appear on different parts of the page thus I'm stuck.
There is only one Stage in swfs - the Stage is effectively the background; and you cant have more than one background.
"Problem is, those images need to appear on different parts of the page" - why cant you adjust the position of the images?
Use swf 100x100 % of browser window with transparent bg (wmode='transparent'), load images and place them in appropriate position. Main problem how to calculte coordinates for thumbnails... ^)
And flash with transparent bg very slow too...

iTunes API: get 100x100 px icon of an App

I'm using iTunes API to get some informations about apps in App Store.
Reading the documentation I saw that "artworkUrl100" parameter, taken from JSON request, will get me a 100x100 icon of the app.
I notice that this not works always, and sometimes it contains the url of a biggest icon.
Is there a way to get with certainty this icon (100x100 px)?
You can do that like this.
Let say this is your link:
http://a223.phobos.apple.com/us/r1000/049/Purple/e0/ed/59/mzi.qaoavtgs.png
(from "artworkUrl512").
You just have to add .100x100-75 before .png like this
http://a223.phobos.apple.com/us/r1000/049/Purple/e0/ed/59/mzi.qaoavtgs.100x100-75.png
Also ju can adjust icon size you need by adding different values like .150x150-75. Only problem is that this -75 part depends on icon size. it can also be -50 for smaller or -65 for middle size icons. I still did not figure that out.
Hope this helps you.
EDIT:
You do not have to worry about .jpg or .jpeg. You can replace all with .png it will work.

Custom images for HTMLLoader

There is powerful HTMLLoader component for AIR wrapped in mx:HTML for Flex.
I want to supply images manually (ideally from bytes) for mx:HTML, which will display my generated content. The point is to pack all resources in the application without external files. I can pack different html pages in the app and switch them when mx:HTML dispatches Event.LOCATION_CHANGE. Now I want the same for images. What do you suggest?
Solved! Went through several stages:
Make HTMLLoader's background transparent with paintsDefaultBackground="false" and backgroundAlpha="0". Get notified of pictures location with javascript and draw them on HTMLLoader's graphics. This is complex and has problems with resizing (pictures get shifted), but was almost done...
Next idea - use <canvas> to draw images on them, sending data to javascript.
While reading canvas tutorials, stumbled upon data URI scheme, which does exactly what I needed in simplest possible way. Images are embedded in html page in base64 encoding.

How to capture zoomable image as one high resolution image?

I would like to capture a zoomable image at a high resolution zoomed at 3x. Do you know of a way I can piece this image together without having to do it manually? Here is the image
After using bhups' solution, tweaking outputxand outputy for a good while, I tried something else.
I went back to the object page (in the above example, here), took the thumbnail image URL (http://www.metmuseum.org/Imageshare/ep/regular/DP145931.jpg), replaced regular with zoom and to my surprise got what I presume is the full image, with less effort:
http://www.metmuseum.org/Imageshare/ep/zoom/DP145931.jpg
You can tweak the URL to get the job DONE. Here is the URl for 3x image. http://media.metmuseum.org/mgen/metzoom/zoom3.ms?img=DP145931.jpg&wrapperid=11&outputx=1200&outputy=1601.067378252168&level=1&x=0&y=0&backcolor=0x00000
outputx and outputy are the output image dimensions. level implies the zoom level. and x and y are the top left corner of the selected rectangle.