Is there some easy way to scale an image to a maximum size?
Looking for some some easy way to keep file sizes down and scale images that are uploaded from the app to max 640 width for example.
I have googled several solutions, from module Ti.ImageFactory to just put it into an ImageView with a size, and get the blob back again (which should make it scaled?). The Ti.ImageFactory module seems very old though, several years ago updated if you look at GIT. Also the zip files for download seems to be missing on git...
Ex.
Titanium.Media.openPhotoGallery({
success:function(event)
{
Ti.API.info('Our type was: '+event.mediaType);
if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO)
{
// HERE event.media needs to be scaled to a max
// size... for example 2 MB data, or max 960 px
// width/height or something similar
uploadPhoto(event.media);
}
},
cancel:function()
{
Ti.API.info("Photo gallery cancel...");
},
error:function(err)
{
//Ti.API.error(err);
Ti.API.info("Err: "+err);
alert(L("AN_ERROR_OCCURRED"));
},
mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO]
});
What you are looking for is the function imageAsCropped or imageAsResized.
Let me know if you need Further help.
You can use the size property.
size : Dimensionreadonly
The size of the view in system units.
Although property returns a Dimension dictionary, only the width and
height properties are valid. The position properties--x and y--are
always 0.
To find the position and size of the view, use the rect property
instead.
The correct values will only be available when layout is complete. To
determine when layout is complete, add a listener for the postlayout
event.
Documentation Link
I ended up using ti.imagefactory module.
The zip files for android and ios I found here:
https://github.com/appcelerator-modules/ti.imagefactory/releases
Example can be found here:
https://github.com/appcelerator-modules/ti.imagefactory/blob/stable/ios/example/app.js
I used code from the examples in my app and it seems to work fine!
Related
I am new in TYPO3, and I am trying something simple, add an image.
Iam doing the following:
I added Content Element "Text & Images"
In the tab "Images" i uploaded an image 1920 x 262
Save
The image loaded is the resolution 600 x 81, i don't understan why.
In the properties i try set 1920 in the field width but same.
In the future i want to know how establish the srcset but first the simple.
(sorry my english)
Sorry to confuse you but there are some rules applied to the maximum size which date back to those days where 600 was already quite large.
the following typoscript constants are relevant:
styles.content {
maxW = 600
maxWInText = 300
}
Depending on the selected value of the field Position and Alignment, one of those 2 applies. So If e.g. "in text, right" is selected, the maximum width is 300.
As a solution you can override the constants to same values which fit more properly.
Most people don't use the default content elements anymore and create custom ones using extensions like mask or dce or without any 3rd party code.
Im trying to achieve something like this. These were recorded from some sites I came across. Im talking about how it uploads images almost instant, not about template.
I used a 3.5 mb image.
https://www.youtube.com/watch?v=cnGsJuyWs9s
So far I've managed to achieve this by copy/pasting codes:
http://adspottest.cf/simple-thumbnails.html
I don't have lot of knowledge in these things. I managed to do this with the knowledge I picked up here and there.
My questions are:
When scaling is on, if I upload several big images at once (like 2mb, 3mb), some images don't generate the preview correctly.
When scaling is off, above error doesn't occur. But it doesn't upload image almost instantly. Is it possible to turn scaling off AND upload the images instantly?
Im trying to get this work for a classified site. In this site the placeholder for image is a fixed one (640 x 480).
As you can see I have set scaling.sizes: maxSize option to 640
If I upload a 5500 x 3010 image; it will be scaled to 640 x 350. This is OK as it doesn't go over the website placeholder max width.
But if I upload a 3010 x 5500 image; it will be scaled to 350 x 640. That means it goes over the placeholder max height. I need it to be scaled to 263 x 480.
So is it possible to set max width AND height?
Thanks
Not sure I understand what you mean by "upload images instantly". Files are always uploaded as quickly as your network connection allows. Also, there are no known issues with the latest version of Fine Uploader regarding image preview generation. This is a stable feature that hasn't changed much in some time. If you are able to reproduce what you believe to be a bug, submit a bug report with all of your code and detailed reproduction steps in the project's issue tracker at https://github.com/FineUploader/fine-uploader/issues/new.
Regarding your final question, all images will be scaled proportionately, taking aspect ratio into account. As a result, you are asked to provide the largest length or width. Which you provide is not significant - you should simply provide the largest size of any side and Finr Uploader will scale it appropriately. There is no feature that allows you to specify both a max width and height. Please file a feature request if you'd like to see this in a future version.
I have Mediawiki 1.21.2 installed. I have also set up ImageMagick on my server and have enabled it in LocalSettings.php. I have already read the Mediawiki's Images manual and I just need to clarify this:
If I am adding a plain image without adding the "thumb" option, will the image be automatically resized for the width I have mentioned or will it only skrink the dimension to that size but still has the original file size? For example, if I using this:
[[File:Sample_Image.jpg|250px]]
In the above statement, I can see that the image will be displayed with the maximum width of 250px. Lets say, if the original image is like 800px X 600px with a file size of 2MB, will the re-sized image for the above dimension will be reduced to only a few KB when the image is reduced to a width of 250px (or) will the image size shown in the article page will still have the original filesize of 2MB but only shrinked to 250px width but doesnt reduce the original filesize? I am just wondering since a lot of my users upload big pictures and these pictures have big file sizes. At the moment, I have added the image like this in my templates:
<div class="main_article_image">[[File:Sample_Image.jpg]]</div>
and then using css, I have minimized the image size like this:
.main_article_image {
max-width: 250px;
height: auto;
}
The current method resizes the images in the articles pages but the file size for these images are still huge and the article page takes too long to load. So I manually resize all images and upload a smaller size for images each time that takes more manual work. Therefore, I am trying to find out if adding the 250px with the image tag like: [[File:Sample_Image.jpg|250px]] will automate this work for me!
I have these settings on my LocalSettings.php for imagemagic:
$wgEnableUploads = true;
$wgGenerateThumbnailOnParse = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/local/cpanel/3rdparty/bin/convert";
Can someone please confirm if this will work? Am I doing it the wrong way by resizing it via css? I know adding "thumb" parameter resizes the image, but will it work the same if for plain images without the thumb parameter? If it will, then I need to edit all of my templates and I just want to confirm before I go ahead changing the templates. Anyone who can clarify this will be helpful for me.
Yes, it seems that a smaller image file is generated even without the "thumb" parameter.
For example if you check the help page on images with the example "[[File:Example.jpg|50px]]" and check the url of the small image that is displayed, you'll see that it uses the thumb version /thumb/a/a9/Example.jpg/50px-Example.jpg instead of the full-size version /a/a9/Example.jpg
I have uploaded a photo in WordPress. I am trying to post a thumbnail of the image using a predetermined width while constraining the height proportionally.
In functions.js:
add_image_size('width-130', 130, 0, false);
On the page that outputs the thumbnail:
the_post_thumbnail('width-130');
According to the WordPress docs(http://codex.wordpress.org/Function_Reference/add_image_size), it says:
WordPress will create a copy of the post thumbnail with the specified
dimensions when you upload a new thumbnail.
Currently it is outputting the full thumbnail image with a width attribute of 130. This still requires the full size image to load, which is not what I want. I would like for WordPress to create an actual copy of the post thumbnail with the correct dimensions, and not just to set the width attribute. How can I achieve this?
I discovered my mistake.
Since I had not re-uploaded the image file, it was still trying to access the full size image which was the assigned image for that post, while adding the width attribute. Once I re-uploaded the image, the add_image_size() function is now actually creating a copy of the thumbnail with the correct dimensions.
I apologize for asking this question. If the community wants, I can close it but I figure it might be good reference for WordPress newbies such as myself.
Use this plugin to regenerate thumbnails.
http://wordpress.org/plugins/regenerate-thumbnails/
In case anyone runs across a similar problem, this may help. add_image_size generates derivatives that are smaller, but not bigger or the same size. Thus if you are trying to make a monochrome derivative image, uploading an image the same size as the monochrome, it will not be available and techniques like this one won't work.
i'm using joomla and want to restrict the user profile image size(dimension).
it is default to 10Mb but i want to restrict the image dimension something like 240x320 and below can be uploaded..
thanks..
You should hack into the joomla code for that particular upload thing and use
code like this for it:
list($width, $height) = getimagesize($image_file);
if ($width == 240 && $height == 320)
{
// nice proceed
}
else
{
// oops, invalid dimensions
}
I suspect you should place this code in controller of the plugin/component you are using the upload feature of.
I haven't used Joomla but you should see:
How to get image height and width using java?
If you are able to load the image into memory you could use Java's awt.Image class to get the width and height of the image and reject the image or scale the image to the desired size. Have a look at:
http://java.sun.com/j2se/1.5.0/docs/api/
I know that you can use JavaScript with Joomla so perhaps this would be worth a view:
link text - Uses javascript to get image dimensions.
I hope this is some help to you.