tesseract icon indicating copy to clipboard operation
tesseract copied to clipboard

Wishlist: Read/Save from Stream on Pix

Open haf opened this issue 10 years ago • 5 comments

It would be great if a few of the methods from https://tpgit.github.io/Leptonica/pngio_8c.html were exposed, such as reading/saving to streams for Pix. That way there's no need to create lots of files on disk during normal operations.

haf avatar Oct 25 '15 20:10 haf

I don't think this is possible as the in memory streaming (i.e. pixReadMemPng()) is not available on windows. That being said most of the api's do support loading a Pix from an in memory array provided you know the image format (i.e. if it's a Tiff or Jpeg etc). Obviously this is not as efficient as loading from a stream but might be the best compromise.

charlesw avatar Oct 30 '15 23:10 charlesw

Hi Charles, I am interested in this as well, does the current pre release offer any support for this ? Or can you maybe provide some info on how to perhaps pass a file as a memory stream to the pix ?

Kind regards,

Helgard Wagener

ghost avatar Aug 08 '17 09:08 ghost

The need for reading from stream/byte array is even more essential now that the package supports .NET Core. Understandably none of the System.Drawing.Bitmap related API (ex: PixConverter) are available for .NET Core so the only way to load an image is via Pix.LoadFromFile and this only takes the path to a file on disk. Though there is Pix.LoadTiffFromMemory it only supports TIFF files.

Another option is to use the System.Drawing.Common package to enable PixConverter for .NET Core.

sansjunk avatar Dec 26 '18 10:12 sansjunk

I just enabled BitmapToPixConverter using System.Drawing.Common package and it works great so this definitely is one way to go.

sansjunk avatar Dec 26 '18 10:12 sansjunk

I was thinking of splitting of the System.Drawing (i.e Bitmap) support into a separate package might be the way to go here. It should be possible to target it at System.Drawing.Common for .Net core support as you suggest.

Direct support for reading from a .net stream is probably a no go as Leptonica understandable doesn't support this 🙂

On Wed., 26 Dec. 2018, 21:53 Santosh Patil <[email protected] wrote:

I just enabled BitmapToPixConverter using System.Drawing.Common https://www.nuget.org/packages/System.Drawing.Common/4.5.1 package and it works great so this definitely is one way to go.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/charlesw/tesseract/issues/219#issuecomment-449949171, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPzyHLLmMU6pvnzPUF02NM_kyQboy9jks5u81UogaJpZM4GVSH0 .

charlesw avatar Dec 27 '18 08:12 charlesw