charlesw / tesseract

A .Net wrapper for tesseract-ocr
Apache License 2.0
2.25k stars 743 forks source link

Wishlist: Read/Save from Stream on Pix #219

Open haf opened 8 years ago

haf commented 8 years ago

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.

charlesw commented 8 years ago

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.

ghost commented 7 years ago

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

sansjunk commented 5 years ago

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 commented 5 years ago

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

charlesw commented 5 years ago

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 <notifications@github.com 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 .