I searched about re-sizing images all over the place and they all use picturebox and Image control trying to fit an image inside it without distortion of the image.
In my case I have an image of 2048X900 of size but the image is stretched in width I need to read it from a file, repair it by changing the aspect ratio of the image, and store it back. I leaned I can't do directly on the image and some use control to do all this steps.
Any suggestion of I have to use a control to change the ratio of an image
thanks
When you choose to resize an image into a different aspect ratio than the original's, you'll need to decide how you'd like that to happen. There are various ways, like stretching (as you already mentioned), padding (resizing the image and filling the padding with whitespaces or anything else), or cropping the image (which means that you'll need to choose which parts of the images remain visible and which ones don't).
There are quite a few of ways to perform such image resizing, either locally with a software or using cloud services.
For example, with Cloudinary you can upload an image and resize it to any dimensions you'd like, including altering the aspect ratio. Everything is done seamlessly on the fly and in the cloud.
For more information:
http://cloudinary.com/documentation/image_transformations#aspect_ratio_based_cropping
Disclosure - I work at Cloudinary.
Related
I know that CEF has an image resizer that can automatically fix image sizes, but do we have the best practices when it comes to Image sizes/resolution/etc. ?
The size of images are less important than the shape of them. The images in the catalog will be a square shape. So any images that are rectangular may not render as well in the catalog.
The higher resolution the image, the better it will look. The lower the resolution, the faster an image will render on the page. There is a balance between those two. Obviously having 3 GB image file will not work but you don't want pixilated images either. Typically this is a data issue that can be addressed by the client as the project progresses.
If that answer isn't sufficient for the client, tell them to shoot for images in a close to square shape between 1 and 5 MB and then decide whether they would like to change at a later time for more performance or high resolution images.
I'm currently using RN 41.2 and I have questions about resizing images from a url. The url files can get quite large, usually around 2000x2000 and I want to display them way smaller probably around 25x25.
Is there an equivalent iOS Image prop for the 'android only' resizeMethod?
When resizeMethod='resize' it changes the size of the large encoded image before it is decoded and so the images display almost immediately in the smaller size and it's great.
But for iOS I'm using resizeMode (contain, cover, etc) and it displays the image correctly but it always takes a bit of time for the images to actually appear, which is totally understandable it's just annoying.
Am I missing something here? It seems like resizeMode should do the same thing the resizeMethod does but it clearly does not
resize mode property decides how the RAW image should be fit inside its frame (cover, contain, stretch, center, repeat)
refer https://reactnative.dev/docs/image#resizemode
In addition for android we can choose the mechanism that should be used to resize image that is to scale , resize or auto using resizeMethod prop.
refer https://reactnative.dev/docs/image#resizemethod-android
basically resizeMode instructs how to resize the image and resizemethod defines what mechanism to use for resizing
This is provided as there exists some issues in android when the frame size and RAW image size varies significantly (too large image: too small frame or too small image and too large frame) and there can be significant delays or design breaks while rendering as auto selection of resize mechanism isnt optimal.
You can escape without setting resizeMethod manually (defaults to auto) most times but it causes issues in before mentioned scenarios.
resizeMode and resizeMethod are 2 properties that the Image component has in RN.
resizeMode: Determines how to resize the image when the frame doesn't match the raw image dimensions.
It can take cover, contain, stretch as values.
resizeMethod: It can be used to resize the image when the image's dimensions differ from the image view's dimensions.
It can take auto, resize, scale as values.
For more you can refer https://facebook.github.io/react-native/docs/image.html
I use the Kupu editor in Plone3 to insert images in the website, automatic scaling images, and make a smaller thumb with a link to the original image.
This is a tutorial of how we do that:
http://www.contentmanagementsoftware.info/plone-book/kupu/insert-image-properties/index_html
Kupu creates a new scaled image (not only scaling with css, but scaling it for real), and the result is that images become a little blurry. I don't know if this issue is related to this document.
The question comes to my mind. Is there anybody who find this issue too? Is there any way to fix it?
I think the only way to achieve a great quality images is scaling them manually with photoshop or some graphic editor. But seems that Kupu doesn't allow to do that. You must swallow with its manners and upload its self-generated images.
Well, a bit too localized, but we find main error. I want to respond in case that any user will be in the same situation...
Kupu scale images to a certain width and height. And later, the css rescaled again a little bigger, making blurry images.
That is the main problem, we reduced an image, then enlarged it browser-side again. We didn't notice until now that there was css behind the kupu implementation and "overriding" (so to speak) our configuration.
I have a client who insists on "crisp" images on his Web pages. One image he gave me was 2592 pixels wide, but the page is only 940 pixels wide. No problem, I just resize the images using Photoshop but there is a noticeable drop in quality, lots of jagged edges. I expect a loss of quality when resizing to one-third the size, but I thought I could do better. So what I did is take the original image and have the browser (Chrome) resize it to 940 pixels wide. Yes, I understand this is the absolute worst thing to do but I was just experimenting. It turns out the browser does a much better job of resizing than Photoshop -- I don't get the jagged edges and the picture looks fairly close to the original in quality.
So what's the deal here? Why is Photoshop not as good as resizing as Chrome (IE8 and Firefox do just as good a job too)? I've tried tweaking Photoshop's resampling options but have seen no real difference.
There are a couple of different things to take into account when scaling images in photoshop:
1.) File type+compression
You're going to want to make sure that if you use a filetype with lossy compression (i.e. JPEG) that you set the quality >8, or you will see a noticeable drop on quality.
2.) Resample method
Photoshop provides a few different resampling methods which effect how pixels are combined when scaling down. Below are links to some images that illustrate where you can modify this when scaling.
Image->Image Size...
http://cl.ly/3W3M0b3W3H0G1Y452L15
There is a drop-down on the bottom of this window:
http://cl.ly/0o463J2J0e2L1u0C1U26
Likely what you're experiencing is that your image is resampling using "Nearest Neighbor" or Bilinear".
Give it a go.
You can try using a browser-based script such as TimThumb: http://code.google.com/p/timthumb/
You really do need to resize the image instead of shrinking a huge image just to display. This script will create copies of your image in different sizes and if I remember correctly, it even supports some sort of caching.
Ive had it resize pretty large images for me to very small thumbnails and it always looked sharp.
Photoshop and web browsers handle resizing differently. I don't use Photoshop, so I can't help you with that..
However, if you want that the picture looks like resized by a web browser, then resize it with a web browser! Take a screenshot and cut the resized picture, creating another one which you can really use on the site.
What is the best way to store images for web-sites?
What size I should not exceed?
Now, I save all interface-files in png (mostly in sprites) and usual images in jpg's. Some images are about 100-150Kb.
What quality and compression should I choose while saving images?
Preparing Images
To prepare images for presentation on
the Web, follow these steps:
Begin a new file. If it’s a photo or original artwork, use 300 dpi as
the resolution. If you are creating
something simple, set the resolution
to 72 dpi.
Use the drawing, text, shape and other tools provided in the graphics
program to create your image.
Save your file in the native file format (a file type meant for editing
that is specific to the image editing
program) of the program you are using.
For example, a Photoshop document
creates files with a ".psd" extension.
If you need to make a change or edit
later, do it in this file rather than
on the Web.
If necessary, lower the resolution of the image to 72 dpi.
If necessary, resize the image to the height and width in pixels
specifications desired.
Save the file in a Web-ready file format, usually a GIF (most programs
give you several choices for file
types), finding a balance between the
way the file looks and an appropriate
file size. Some image programs will
let you preview the final file output,
whie in others, you have to save it
and load it in the browser to see the
final effect.
Preparing Photographs
To prepare photographs for
presentation on the web, follow these
steps:
Download the photo from your digital
camera or scan in the photograph. The
process for this varies depending on
the software bundled with your scanner
or camera. The image will probably end
up in "Your Photos" on Windows, or the
"Photos" folder on a Mac, unless you
chose some other folder as the default
destination.
Use the color correction, drawing, text, shape, and other tools provided
in the graphics program to alter and
improve your image.
Save a copy of your file in the native file format of the program you
are using. Make later changes or edits
in this file rather than on the web.
With photographs, save an untouched
version of the photo in case you want
to use it again for another purpose.
If necessary, lower the resolution of the image to 72dpi.
If necessary, resize the image to the height and width in pixels
specifications desired.
Save the file in a web-ready format, usually a JPEG, finding a
balance between the way the file looks
and an appropriate file size.
Making images web-ready is all about
compromise. In general, the better
your image looks, the larger the file
size will be. The larger the file
size, the longer it will take to
download. Your job is to find a
compromise between quality and file
size. Some things to consider are:
Is this image conveying crucial information? If so, go for higher
quality.
Is the image on a page with a lot of other images? If so, make the file
size smaller.
Will your web visitor be able to detect that the quality of a photo or
image isn’t very good?
Make images of people fairly high quality because visual acuity is
strongest with people’s faces.
(Source)
For your images, here is a tip:
Do not scale images in HTML
Web page designers sometimes set image
dimensions by using the width and
height attributes of the HTML image
element. Avoid doing this since it can
result in images being larger than
needed. For example, if your page
requires image myimg.jpg which has
dimensions 240x720 but displays it
with dimensions 120x360 using the
width and height attributes, then the
browser will download an image that is
larger than necessary.
(Source, see another tip)
This all depends on what the image is for. If you're generally adhering to a web-safe palette, gifs will come out smaller and clearer than a jpeg. Jpeg's are for photos. For jpegs to handle websafe colors well, you need to save at 88%+ quality, which increases file size. Png's generally have the best quality, and in some cases (when you don't need transparency) can come out smaller than jpgs, and comparable to gif. So, for jpeg photos, 80 quality, (sometimes even 75 for smaller images) will get you decent results and small filesize. Use gifs / png for site imagery generally. As far as images on a page, I try not to exceed 30kb total, assuming the page isn't something that is focused on photos / imagery. Hope this helps.
It depends on what your image is of, and what the quality needs to be, whether you choose quality over page loading etc.
I personally save all mine in .png but IE has a problem rendering the colour correctly in .png so if you are using them for aestetical purposes I would save .jpg
As to the size of the image, like said it depends really on the quality you want your image and how it affects performance if it is a large file.
i usually use save for web mode that exists in photoshop. obviously the lower size is best. The sizes that you talking about (100-150) are good or not in relation to the dimension of the image. Anyway i advice you to use sprites and when possible in jpeg format.
something like 75-80% quality are good enought to a good quality of image
And please pay attention to the cmyk mode, that cause problems in some browsers