Is there an equivalent to background-size: cover and contain for image elements?

Solution #1 – The object-fit property (Lacks IE support) Just set object-fit: cover; on the img . body { margin: 0; } img { display: block; width: 100vw; height: 100vh; object-fit: cover; /* or object-fit: contain; */ } <img src=”https://loremflickr.com/1500/1000″ alt=”A random image from Flickr” /> See MDN – regarding object-fit: cover: The replaced content … Read more

How to make an app’s background image repeat

Ok, here’s what I’ve got in my app. It includes a hack to prevent ListViews from going black while scrolling. drawable/app_background.xml: <?xml version=”1.0″ encoding=”utf-8″?> <bitmap xmlns:android=”http://schemas.android.com/apk/res/android” android:src=”https://stackoverflow.com/questions/2706913/@drawable/actual_pattern_image” android:tileMode=”repeat” /> values/styles.xml: <?xml version=”1.0″ encoding=”utf-8″?> <resources> <style name=”app_theme” parent=”android:Theme”> <item name=”android:windowBackground”>@drawable/app_background</item> <item name=”android:listViewStyle”>@style/TransparentListView</item> <item name=”android:expandableListViewStyle”>@style/TransparentExpandableListView</item> </style> <style name=”TransparentListView” parent=”@android:style/Widget.ListView”> <item name=”android:cacheColorHint”>@android:color/transparent</item> </style> <style name=”TransparentExpandableListView” parent=”@android:style/Widget.ExpandableListView”> <item name=”android:cacheColorHint”>@android:color/transparent</item> … Read more

Inputting a default image in case the src attribute of an html is not valid?

You asked for an HTML only solution… <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”> <html lang=”en”> <head> <title>Object Test</title> <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″> </head> <body> <p> <object data=”http://stackoverflow.com/does-not-exist.png” type=”image/png”> <img src=”https://cdn.sstatic.net/Img/unified/sprites.svg?v=e5e58ae7df45″ alt=”Stack Overflow logo and icons and such”> </object> </p> </body> </html> Since the first image doesn’t exist, the fallback (the sprites used on this … Read more

Capture Image from Camera and Display in Activity

Here’s an example activity that will launch the camera app and then retrieve the image and display it. package edu.gvsu.cis.masl.camerademo; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; public class MyCameraActivity extends Activity { private static final int CAMERA_REQUEST = 1888; private ImageView imageView; private static final int MY_CAMERA_PERMISSION_CODE … Read more

CSS3 Rotate Animation

Here is a demo. The correct animation CSS: .image { position: absolute; top: 50%; left: 50%; width: 120px; height: 120px; margin:-60px 0 0 -60px; -webkit-animation:spin 4s linear infinite; -moz-animation:spin 4s linear infinite; animation:spin 4s linear infinite; } @-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } } @-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } } … Read more

How do I convert a numpy array to (and display) an image?

The following should work: from matplotlib import pyplot as plt plt.imshow(data, interpolation=’nearest’) plt.show() If you are using Jupyter notebook/lab, use this inline command before importing matplotlib: %matplotlib inline A more featureful way is to install ipyml pip install ipympl and use %matplotlib widget see an example.

How to resize an Image C#

This will perform a high quality resize: /// <summary> /// Resize the image to the specified width and height. /// </summary> /// <param name=”image”>The image to resize.</param> /// <param name=”width”>The width to resize to.</param> /// <param name=”height”>The height to resize to.</param> /// <returns>The resized image.</returns> public static Bitmap ResizeImage(Image image, int width, int height) { … Read more

How to generate a Dockerfile from an image?

How to generate or reverse a Dockerfile from an image? You can. Mostly. Notes: It does not generate a Dockerfile that you can use directly with docker build; the output is just for your reference. alias dfimage=”docker run -v /var/run/docker.sock:/var/run/docker.sock –rm alpine/dfimage” dfimage -sV=1.36 nginx:latest It will pull the target docker image automatically and export … Read more

Setting WPF image source in code

After having the same problem as you and doing some reading, I discovered the solution – Pack URIs. I did the following in code: Image finalImage = new Image(); finalImage.Width = 80; … BitmapImage logo = new BitmapImage(); logo.BeginInit(); logo.UriSource = new Uri(“pack://application:,,,/AssemblyName;component/Resources/logo.png”); logo.EndInit(); … finalImage.Source = logo; Or shorter, by using another BitmapImage constructor: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)