Free Support Forum - aspose.com

How to get size of font

Hi team,

Is this possible to get font size and font name from jpeg images.please kindly help me to get the same.

Sample1:sample2.jpeg (719.3 KB)

Thanks & regards,
Priyanga G

@priyanga,

I have observed your requirements and regret to share that JPEG is a raster image and there is no way one may possibly get font related information even text from it. I hope the shared information will be helpful.

Hi @mudassir.fayyaz,

Thanks for your feedback

please, kindly help me to how to use the get font size() method to get the font size for simple jpeg images.

Thanks & regards,
Priyanga G

@priyanga,

I have observed your comments and like to share that there is no way you may get the fonts or size related information from a JPEG image since it is a raster image.

Hi @mudassir.fayyaz,

Thanks for your feedback.

Other than the raster image .please let me know how to use this method to get the font size.

getSize()
Gets the em-size of this Font measured in the units specified by the P:Aspose.Imaging.Font.Unit property.

Thanks & regards,
Priyanga G

@priyanga,

You can get fonts related information for PSD images using following sample code on your end.

public static void UpdateTextLayer()
{
    String filepath = @"";
    
    using (PsdImage image = (PsdImage)Image.Load(filepath + "first file.psd"))
    {
        foreach (Layer layer in image.Layers)
        {
            if (layer is TextLayer)
            {
                TextLayer textLayer = (TextLayer)layer;
                Console.WriteLine("Text is: " + textLayer.Text);
                Console.WriteLine("Font Name : " + textLayer.Font.Name);
                Console.WriteLine("Font Height is: " + textLayer.Font.Size.ToString());
                Console.WriteLine("If Font Bold : " + textLayer.Font.Bold);
                Console.WriteLine("If Font Italic : " + textLayer.Font.Italic);
                Console.WriteLine("Fontt Height is: " + textLayer.Font.Size.ToString());

              //  textLayer.UpdateText(textLayer.Text + "test");
            }
        }

        image.Save(filepath+"asianSymbolsResult.psd", new PsdOptions { CompressionMethod = CompressionMethod.RLE });
        image.Save(filepath+"asianSymbolsResult.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
    }
}

Hi @mudassir.fayyaz,

Thanks For your feedback

How to use this method in java .please ,kindly help me to get the font related information.

Thanks & regards,
Priyanga G

@priyanga,

I have observed your comments and shared sample code with you. This will help you to achieve your requirements. Please share feedback with us if there is still an issue.Font.zip (758 Bytes)

Hi @Adnan.Ahmad,

Thanks for your feedback.

The previously shared sample code was useful for me.please,kindly help me to find the font size for the sample image.

sample1: sample2.zip (549.9 KB)

Thanks & regards,
Priyanga G

@priyanga,

I have observed the image shared by you. This is a JPEG image and shared earlier that there is no possibility to get the font related information from JPEG. The sample codes that have been shared with you earlier are applicable only to PSD images. Please refer to my response shared below as well.