So currently I'm trying to render a large image for example:
I tried CachedNetworkImageProvider from pub_dev.
I also tried various different Providers with combination of Image widget. None of them worked.
The only widget that allows me to render the image is photo_view which renders the 4k image but has Zoomable feature that I don't want to have.
How can I remove this feature and fit with BoxFit?
Libraries tried to render the image:
extended_image
image_ink_well
flutter_advanced_networkimage
When using PhotoView you can disable the zoom functionality.
IgnorePointer( // The PhotoView widget thinks there's nothing happening
// because you're catching any clicks that happen here.
child: PhotoView(
minScale: PhotoViewComputedScale.covered,
maxScale: PhotoViewComputedScale.covered,
),
),
You can read more about the PhotoView class here: https://pub.dev/documentation/photo_view/latest/photo_view/PhotoView-class.html
Related
I'm working on a basic design app where the user can upload images to a canvas, drag them around and resize them. The problem I have is resizing the image with a mouse drag. I'd like the user to position the mouse pointer on either corner of the bitmap image and drag either towards or away from the bitmap to resize it proportionally. I'd be grateful for any code or suggestions.
Lanny mentioned that you had this question here. ZIM, which is based on CreateJS has this functionality built in - it is called transform(). We also have an uploader built in called Loader().
Here is the code that you would use inside the ZIM template available on the code page at ZIM https://zimjs.com
const loader = new Loader().center();
loader.on("loaded", e=>{
e.bitmap.center().transform();
// or if you want multiple files
// loop(e.bitmaps, bitmap=>{
// bitmap.center().transform();
// });
loader.removeFrom();
stage.update();
});
Below is an image that has been loaded. You can try it here https://zimjs.com/explore/uploadresize.html. The transform interface will go away when the user clicks off the image and then comes back when they click on the image. There are various options for all of this that you can read about in the Docs available on the ZIM site.
All your regular CreateJS will work and you will find that ZIM is helpful in many other ways too! Aside from transform() there is drag() for normal dragging, and gesture() for pinch zoom and rotate - you would use one or the other of these not combined.
I am trying to view Gigapixxel image in flutter App.I want to Optimize the image size for reduce Data Usage and save the memory when open the image. User should be able to Zoom that image. How I can do that in Flutter ? (I want to zoom Image as google map)
Use this dependency Flutter Native Image its easy to use and will do the job you are looking for. It will reduce the size of the image and for zooming in just use this dependency and wrap it up with any widget you want. Photo View
Simple Usage of photo view
Container(
child: PhotoView(
imageProvider: AssetImage("your asset"),
)
);
Flutter native image:
To crop
File croppedFile = await FlutterNativeImage.cropImage(file.path, originX, originY, width, height);
To compress image:
File compressedFile = await FlutterNativeImage.compressImage(file.path,
quality: quality, percentage: percentage);
You have to give it a file from the file system and optionally provide a quality (1-100) and a resizing percentage (1-100). Each platform will use it's proper tools to handle the resizing.
The documentation of each dependency is your friend have a look at it, read a bit and use the code according to your needs.
Hello does anyone know how i can mask a text and photo in flutter? I already have my image with text on the screen. For example: my text would be Lion and my photo of these lions are behind it. How can i make a mask like you can in photoshop?
See this photo for example:
I'm not sure this answers your question. It's a simple version of text masking but instead of masking an image this MIN REPRO EXAMPLE shows masking gradient colors:
ShaderMask(
shaderCallback: (bounds) => RadialGradient(
colors: [
Colors.red,
Colors.green,
],
).createShader(bounds),
child: const Text('exclusive'),
),
Unfortunately, as of writing ShaderMask is not supported yet for web online for iOS/Android. Check out more here: https://github.com/flutter/flutter/issues/44152
You may find these answers useful (just again they may not be supported on web yet I don't know about other solutions):
Is there a way to show image inside text in flutter
texture (image) on text in flutter
I've spent about 3 hrs last night trying to determine why the image that I upload via the Media Library Picker field keeps resizing to 200x200 when it is displayed in a blog post.
Its not resized after upload and if I insert that same image into the blog post it retains the original size.
I haven't done anything special, I just edited the Blog Post content definition by adding the Media Library Picker field. When I create new blog post, I click the Add button to select the media and then publish the post.
See sample screencap: http://imgur.com/Ju3Sryp
Thanks for the input!
By default, when you are displaying a media library picker field, it gets rendered by Modules/Orchard.MediaLibrary/Views/FieldsMediaLibraryPicker.cshtml. That template loops over the media parts in the field, and calls Display(BuildDisplay(content, "Summary")). That builds the shapes for each of the media content items pointed to by the field. One of these shapes is going to be a Parts_Image shape in your case. Notice that in the BuildDisplay call, a "Summary" display type was passed in. That means that the Parts/Image.Summary.cshtml template is going to be used to render each image. That template has the following code to render the image:
<img width="200" height="200" alt="#mediaPart.AlternateText"
src="#Display.ResizeMediaUrl(
Width: 200, Height: 200, Mode: "crop",
Alignment: "middlecenter", Path: mediaPart.MediaUrl)" />
This is what resizes the image to a 200x200 cropped thumbnail.
If that's not what you want, you'll have to override one of those templates. I'd recommend creating an alternate for FieldsMediaLibraryPicker.cshtml for the specific filed name that you've been using, and in the code, change the display type from "Summary" to "Detail". This way, the Image.cshtml will get used for each image, and that will not do any resizing.
Image resizes into shape by default. You should enable Shape Tracing Module than reload your page than expand shape tracing tool from page bottom than click on the image than create and change alternate.
I am adding an image to a TinyMCE editor using:
var params = {
src: filename,
title: "Attached image: " + filename,
width: 500
};
ed.execCommand("mceInsertContent", false, ed.dom.createHTML("img", params));
This insert the image correctly in the editor. However, when the user clicks on the image he has the ability of resizing it.
I would like to know if there is a way to:
Prevent the user to resize only in one direction (i.e. how do I keep a fixed aspect ratio for the image)
Completely prevent the user to resize the image
I found a (partial) answer, so I thought I will share it here.
Adding
'object_resizing' : false
In the editor config prevents the resizing.
Note that this is a feature of Mozilla only (e.g. Google Chrome does not allow you to resize the image).
I am still looking for a way of keeping aspect ratio in real time, but I do not know if that is really possible.
You can simply add this little plugin to tinyMCE, I used it and it works very well!
Here's the documentation: Link
You would need to implement a resize handler (for example a jQuery handler).
It might be helpfull to add attributes to your images to save its dimensions or to use one single setting holding the aspect ratio. For this you will adjust the tinymce configuration setting valid_elements to allow those attributes for images - otherwise tinymce would strip them out.
When resize gets fired you grab the new dimensions and adjust the dimensions according to the aspect ratio - eigther adjust using the new width or new heigth (the other value is needs to get corrected).
Example: images have an attribute aspectratio holding the aspect ration
You may place this code in thetinymce setup configuration parameter
setup : function(ed) {
ed.onInit.add(function(ed) {
$(ed.getBody()).find('img').resize( function(event){
$(event.target).css('width', parseInt ( event.target.width * this.aspectratio) );
});
});
}
Update:
I have created a tinymce fiddle to show an example to use with IE.