Manage resource images in Xamarin forms - xamarin

I have been working on Xamarin forms for a long time now but the thing that has always bugged me is what is the better approach to store images in xamarin forms.
I wanted to know which images should I use from PCL and which ones should I put in native resource files or is using PCL images a bad approach altogether.
I went through everything in Local Images and Embedded Images but found nothing related to the better approach among them or performance or anything as such.

At the end after all the research for almost a year I came to the conclusion that the Local Image approach suits me better, even with the case where I had to add it to all three native projects depending what I target.
Reason being the following:
When I use local images I have an option to place different images in different size folders i.e. HDPI, MDPI(Android) and #2x,#3x(iOS)
What the above point does for me is it selects the image it should pick as per the current devices resolution which cannot be achieved with EmbeddedResources
One possible solution to issue mention above was using SVG's but as everyone knows that if the image you are using needs to look pixel perfect SVG's are not your best option as they lose some details here an there as you use them in your mobile devices.
One more cheeky thing I did (but I like to share my dev secrets) was whichever Images in my application were only in one size for all resolutions and platform or at least two of them I incorporated them in the Shared code
Note: Embedded Resource takes a little more time to load then your native Local Images always consider that while using

Related

How would you load (hundreds) of images in a React Native app?

I have to develop a mobile application that will have hundred of "cards" with an image. All images will be locally stored. I have seen that, in React Native, images are loaded using require and a constant file path string as parameter. I can create an array with all images user could need, but I don't know how memory is handled in this situations. Is there a better approach to solve that?
Haven't tried it yet, but react-native-fast-image might be what you are looking for!

Dynamic image resizing in the Cloud for Responsive website

I have a responsive (RWD) website which works OK on mobile devices. My problem is that pictures are sort of "heavy" on smartphones and uselessly large on older phones.
I know there are plenty of tools either offline or online (such as: http://www.resizeyourimage.com/) to resize pictures and I know I could roll my own image resizer with GD and the like (PHP here), but I was wondering if someone here is aware of a way to have images automatically resized.
For example by piping them through a proxy of some kind, such as:
http://cloudservice/w_320/http://myserver/mypic.jpg" />
A free service highly preferrable.
This way I wouldn't have to retrofit old pictures nor is it necessary to provide multiple versions of the same picture.
I hope my question makes sense...
There are many such services, and a similar question has been asked before.
All reliable solutions will also requires a tiny bit of client-side javascript. Cookies don't work on the first page load (which is most of them), and sniffing gives useless data if you're doing RWD with breakpoints. Excepting slimmage (and solutions with <noscript> tags), most will download 2 copies of each image (or worse, fail accessibility and SEO requirements).
I favor the DRY & CSS-friendly Slimmage.js, as its author, but there is also Picturefill for those who want art direction support (and are willing to handle the resulting markup complexity). Both can be used with any RIAPI-compliant server-side module, such as ImageResizer (disclaimer of authorship applies here too).
If you have access to a Windows (or linux/mono) server, consider self-hosting.
Dynamic imaging SaaS products appear and fail on a regular basis, so have a backup plan in place to replace the URLs if your SaaS isn't RIAPI-compliant. If your HTML isn't dynamic or can't be post-processed, you're going to have... fun.
A few services (free or in beta):
CDNConnect (RIAPI-compliant third-pary service based on ImageResizer)
BoxResizer (free, but uptime not guaranteed)
Sqish
Resizor
Some non-free (and non-compliant) services
http://www.resrc.it/pricing/us
https://responsive.io/plans#pricing-list
https://www.maikoapp.com/
http://www.thumbr.io/plans_and_prices
You should check out WURFL Image Tailor.
Works pretty much as you describe. You refer the images through a proxy like this:
<img src="//wit.wurfl.io/[full-url-to-your-image]">
The proxy will then detect the screen size of the user-agent and resize the image accordingly. This service also take some arguments that allows you to explicitly set height, width and percentage of screen size.
One image resizing service you can use is https://gumlet.com. You can use any image source with it and resize images exactly as per your need.
For example, to get image width of 300 px, you can write
https://subdomain.gumlet.com/image.jpg?width=300
P.S. I work at Gumlet.

Unity 3D: Asset Bundles vs. Resources folder vs www.Texture

So, I've done a bit of reading around the forums about AssetBundles and the Resources folder in Unity 3D, and I can't figure out the optimal solution for the problem I'm facing. Here's the problem:
I've got a program designed for standalone, that loads "books" full of .png and .jpg images. The pages are, at the moment, the same every time the program starts. At the start of the scene for any "book", it's loading all those images at once using www.texture and a path. I'm realizing now, however, that this is possibly an non-performant method for accessing things at runtime -- it's slow! Which means the user can't do anything for 5-20 seconds while the scene starts and the book's page images load up (on non-legendary computers). SO, I can't figure out which of the three things would be the fastest:
1) Loading one asset bundle per book (say 20 textures # 1 mb each).
2) Loading one asset bundle per page (1 mb each).
3) Either of the first two options, but loaded from the resources folder.
Which one would be faster, and why? I understand that asset bundles are packaged by unity, but does this mean that the textures inside will be pre-compressed and easier on memory at load time? Does the resources folder cause less load time? What gives? As I understand it, the resources folder loads into a cache -- but is it the same cache that the standalone player uses normally? Or is this extra, unused space? I guess another issue is that I'm not sure what the difference is between loading things from memory and storing them in the cache.
Cheers, folks...
The Resource folders are bundled managed assets. That means they will be compressed by Unity, following the settings you apply in the IDE. They are therefore efficient to load at runtime. You can tailor the compression for each platform, which should further optimize performance.
We make expensive use of Resources.Load() to pull assets and it performs well on both desktop and mobile.
There is also a special folder, called StreamingAssets, that you can use to put bundled un-managed assets. This is where we put the videos we want to play at runtime, but don't want Unity to convert them to the default ogg codec. On mobile these play in the native video player. You can also put images in there and loading them is like using WWW class. Slow, because Unity needs to sanitize and compress the images at load time.
Loading WWW is slower due to the overhead of processing asset, as mentioned above. But you can pull data from a server or from outside the application "sandbox".
Only load what you need to display and implement a background process to fetch additional content when the user is busy going through the first pages of each book. This would avoid blocking the UI too long.
Optimize the images to reduce the file size. Use tinypng, if you need transparent images, or stick to compressed JPGs
Try using Power of 2 images where possible. This should speed up the runtime processing a little.
ath.
Great answer from Jerome about Resources. To add some additional info for future searches regarding AssetBundles, here are two scenarios:
Your game is too big
You have a ton of textures, say, and your iOS game is above 100 mb -- meaning Apple will show a warning to users and prevent them from downloading over cellular. Resources won't help because everything in that folder is bundled with the app.
Solution: Move the artwork you don't absolutely need on first-run into asset bundles. Build the bundles, upload them to a server somewhere, then download them at runtime as needed. Now your game is much smaller and won't have any scary warnings.
You need different versions of artwork for different platforms
Alternative scenario: you're developing for iPhone and iPad. For the same reasons as above you shrink your artwork as much as possible to hit the 100 mb limit for iPhone. But now the game looks terrible on iPad. What do?
Solution: You create an asset bundle with two variants. One for phones with low res artwork, and one for tablets with high res artwork. In this case the asset bundles can be shipped with the game or sent to a server. At run-time you pick the correct variant and load from the asset bundle, getting the appropriate artwork without having to if/else everywhere.
With all that being said, asset bundles are more complicated to use, poorly documented, and Unity's demos don't work properly at times. So seriously evaluate whether you need them.

Find matching image in Windows 8 App

I'd like to build an app for Windows 8 / Windows Store where a user can take a picture with his device and the app will return an image from a database which looks the closest to it.
For example, you scan the front of a book and you get the right product image from the db.
Now, I know this isn't an easy task and so I was wondering, if there are any libraries working on Win8 I could use.
I heard about tools like OpenCV, SURF and AForge.net, but can I use those on Windows 8?
I hope you guys can give me a point to start.
This is a very general question and thus can only yield a very general answer. Since you are targeting tablet devices you need to remember that they do not have nearly the processing power of a normal PC. Other applications on other devices that offer this type of functionality typically offload a lot of the work to their servers. I believe most of them do very little pre-processing on the device (normalizing to the correct resolution or doing some histogram generation) and then upload that to a server that has the databases and heavy analysis tools to do the comparisons.
The easiest way to start an application like this from the Windows 8 perspective would be to get an application that can take the picture and normalize it to a specific resolution. Once you have that, build functionality to upload that to a server. You then need to implement server code to use tools like AForge to perform the image processing that would allow you to compare images.
There are tons of great resources on how to compare images and you are going to have to wade through them and find ones that work for you. To start you might want to read this thread:
Image comparison - fast algorithm
In the end you need to decide what algorithm works best for the images you want to compare.

Transparent image overlay software for implementation of design

Useful when implementing a design, to make the design pixel accurate.
I've used the pixel perfect plugin for firefox to do this, but it doesn't seem to work anymore. The best would be a separate program that can be used independently of browser. Any recommendations?
I'm working on a javascript tool for developers to manage image overlays: https://github.com/frontfoot/overlay_me
I found another solution though that is corresponding to your need: http://makiapp.com/
My version of the tool is a bit more developer oriented, as you can have a pack of overlaying images loading automatically per project, and also keeping the possibility to inspect DOM elements while overlaying things.
The makiapp tool is a more accessible, designer oriented, where you can upload a local file.
My tool is at its first stage and need feedback BTW ;)

Resources