Is .tif image multipage or not? [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a simple question (I hope it is simple for someone). How could I recognize is .tif (or .tiff) image contains two or more pages, or it is just one image (one "page"). I use .NET. For what? I have an image as input and should process it in some way, and if image consists of several images - choose one method, just one image - another method. I am waiting for any free solution (it can be just .net or any free third-party library). I don't need to split tiff or any other good thing, just something like
Boolean isMultipage = SomeLibrary.IsTifMultipage(filePath);
Thanks!

You could write a method that would determine that for..Perhaps something like this?
public bool IsMultipage(string fileName)
{
using (Image imageFile = Image.FromFile(fileName))
{
FrameDimension frameDimensions = new FrameDimension(imageFile.FrameDimensionsList[0]);
return imageFile.GetFrameCount(frameDimensions) > 1;
}
}

Related

How to write below mentioned swift code in .cs file for xamarin? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 12 months ago.
Improve this question
I am new to xamarin and swift and I am creating a demo and in that, I have to write down some iOS related code which is mentioned below in code but the code is swift and I want to add that code in my .cs file so that I can use it with my UI page and it is giving errors as mentioned in the below image. It would be great if you can guide me with this and provide me with what code should I need to write and where.
UIApplication.shared.open(redirectUrl, options: [:], completionHandler: { success in
if success {
// Handle success.
} else {
// Handle failure. Most likely app is not present on the user's device. You can redirect to App Store using these links:
}
})
This should work for you. My advise, please refer to the official documentation it's all there.
var param = new NSDictionary();
UIApplication.SharedApplication.OpenUrl(new NSUrl("https://google.com"), param, (completed) =>
{
if (completed)
{
}
else
{
}
});

How can I extract written number in a answer sheet(image) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I tried tesseract but it only works on pure text document, can anyone suggest me what to do?
Here is my code for vb.net
Dim pic = New Bitmap(OpenFileDialog1.FileName)
Dim ocr = New TesseractEngine("./dataset", "eng", EngineMode.TesseractAndCube)
Dim page = ocr.Process(pic)
TextBox1.Text = page.GetText
It looks like your answer sheet is well structured. I would focus on extracting a sub-image for each answer, and then running Tesseract in single character mode on that image.
I'm not sure how you get single character mode in whatever Tesseract wrapper you're using, but via command line it's the parameter: --psm 10.
To extract each image, I would use OpenCV (try Emgu for .NET). You may need to first apply a perspective wrap in order to get the image square. You can then use a simple sliding window to get each sub image.
I'm not sure how this will perform in cases where an answer has been crossed out.

HTML5 Capture Attribute on devices image get rotated [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have used html5 camera capture attribute, when user try to capture image from the devices image gets rotated
Do we need to provide any setting on this?
Can we correct the image rotation using C#?
We are successfully using the following code to capture images and it works fine:
var canvas = document.getElementById("canvas")
var video = document.getElementById("video")
// Start video code omitted...
// Capture function
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext("2d").drawImage(video, 0, 0);
var imgData = canvas.toDataURL("image/jpeg")
The image should be fine unless there is some specific hardware configuration not allowing this.
And yes, it is possible to rotate the image using C#. Google it.

pretend to have a file without loading it from harddrive [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
How to pretend to have a file without actually loading a file? The challenge is not to create a temporary file or load anything from a harddrive. I would rather like to keep everything in "memory".
In memory means to me having an existing class which derivates from stream initalized and having that class working like it loaded a file from harddrive but it didnt...
A memory stream isn't a file. It's just data. The concept of setting a filename and extension on a memory stream simply doesn't make sense - any more than it would for a byte[].
You can create a subclass to keep track of the filename, like so
class MemoryStreamWithFile: MemoryStream
{
public string Filename { get; set; }
}

C# Using regex, how to find a language in url [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a class library to add a customized toolbox to a external IE browser.
I'm using SHDocVw to do the back/forward buttons (e. g.). My question is, sense this is multilingual, how can I change the buttons text...
The url give me "/en/" or "/ar/", how can i catch this?
Thanks
With the Mati Cicero answer I managed to do it.
string page = ie.LocationURL;
Regex rgx = new Regex(#"https?://[a-zA-Z0-9.-_]+(/((?'lang'ar|en)|.*))/?");
var lang = rgx.Match(page).Success ? rgx.Match(page).Groups[1].Value : "ar";
You can try the following regex, I tried to make it as much generic as I could:
https?:\/\/[a-zA-Z0-9\.\-_]+(\/((?'lang'es|en)|.*))\/?
You would then examine the group "lang" to see if a match was made.
You would aso like to add more available languages (Added ch and in):
https?:\/\/[a-zA-Z0-9\.\-_]+(\/((?'lang'es|en|ch|in)|.*))\/?
If its always the first directory;
var lang = new Uri("http://sitename.com/en/pages/default.aspx")
.Segments[1].Replace("/", string.Empty).ToLower();

Categories