M Markos Well-Known Member Licensed User Longtime User Oct 6, 2025 #1 Hi All, Is there a library to permit changing the size (width and height) of an image file be it from data array or a file say in jpeg format
Hi All, Is there a library to permit changing the size (width and height) of an image file be it from data array or a file say in jpeg format
Erel B4X founder Staff member Licensed User Longtime User Oct 6, 2025 #2 XUI.LoadBitmapResize. And then save the image. Upvote 0
M Markos Well-Known Member Licensed User Longtime User Oct 7, 2025 #3 Cheers Erel! using a bitmap object would the Resize function achieve the result of resizing the bitmap a code snippet shown below Code: Copy Dim bmpnew0 As Bitmap Dim bmpnew As Bitmap bmpnew0 = LoadBitmap(File.DirAssets, "SomeFile.jpg")) bmpnew=bmpnew0.Resize(320,240,True) out = File.OpenOutput(File.DirInternal, "tmpfile2.jpg", False) bmpnew.WriteToStream(out, 100, "JPEG") Last edited: Oct 7, 2025 Upvote 0
Cheers Erel! using a bitmap object would the Resize function achieve the result of resizing the bitmap a code snippet shown below Code: Copy Dim bmpnew0 As Bitmap Dim bmpnew As Bitmap bmpnew0 = LoadBitmap(File.DirAssets, "SomeFile.jpg")) bmpnew=bmpnew0.Resize(320,240,True) out = File.OpenOutput(File.DirInternal, "tmpfile2.jpg", False) bmpnew.WriteToStream(out, 100, "JPEG")
Erel B4X founder Staff member Licensed User Longtime User Oct 7, 2025 #4 Better to use XUI.LoadBitmapResize. 1. It is cross platform. 2. It most cases it will not load the full image to memory, which can result in out of memory issues with very large images. Upvote 0
Better to use XUI.LoadBitmapResize. 1. It is cross platform. 2. It most cases it will not load the full image to memory, which can result in out of memory issues with very large images.
M Markos Well-Known Member Licensed User Longtime User Oct 7, 2025 #5 Erel said: Better to use XUI.LoadBitmapResize. 1. It is cross platform. 2. It most cases it will not load the full image to memory, which can result in out of memory issues with very large images. Click to expand... Many thanks Erel I will utilise your suggestion as primary given your insight. Although for images 3mb or less it seems to work well using the previous method Upvote 0
Erel said: Better to use XUI.LoadBitmapResize. 1. It is cross platform. 2. It most cases it will not load the full image to memory, which can result in out of memory issues with very large images. Click to expand... Many thanks Erel I will utilise your suggestion as primary given your insight. Although for images 3mb or less it seems to work well using the previous method
tchart Well-Known Member Licensed User Longtime User Oct 8, 2025 #6 Or use Thumbnailator. Has many useful features. Thumbnailator library - Pnd_Thumbnailator - Create image thumbnails (UI/Non-UI/Server) Wrapper is based on Thumbnailator v0.4.20 from HERE. Features: Create high-quality thumbnails from existing images. Option to embed a watermark (such as a logo) in the thumbnails. Transparency of the watermark is adjustable from transparent (0%) to opaque (100%). Supports rotation of... www.b4x.com Upvote 0
Or use Thumbnailator. Has many useful features. Thumbnailator library - Pnd_Thumbnailator - Create image thumbnails (UI/Non-UI/Server) Wrapper is based on Thumbnailator v0.4.20 from HERE. Features: Create high-quality thumbnails from existing images. Option to embed a watermark (such as a logo) in the thumbnails. Transparency of the watermark is adjustable from transparent (0%) to opaque (100%). Supports rotation of... www.b4x.com
LucaMs Expert Licensed User Longtime User Oct 8, 2025 #7 tchart said: Or use Thumbnailator. Has many useful features. Click to expand... I see this is a library for B4J; the question here is about B4A, and it MAYBE wouldn't handle very large images well (but since it's for B4J - Desktop, that shouldn't be a problem). Interestingly: Pendrush said: Work on UI/Non-UI/Server applications. Click to expand... I didn't know about it, thanks for the link, @tchart Upvote 0
tchart said: Or use Thumbnailator. Has many useful features. Click to expand... I see this is a library for B4J; the question here is about B4A, and it MAYBE wouldn't handle very large images well (but since it's for B4J - Desktop, that shouldn't be a problem). Interestingly: Pendrush said: Work on UI/Non-UI/Server applications. Click to expand... I didn't know about it, thanks for the link, @tchart