Converting Syriac to an image.

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
sepoto
Posts: 9
Joined: 2015-07-10T15:29:44-07:00
Authentication code: 1151

Converting Syriac to an image.

Post by sepoto »

Code: Select all

				$sOutputDir = "C:\Users\erics_000\Desktop\Output"

				$sCharsDir = "$sOutputDir\Chars"

				$sCombDir = "$sOutputDir\Comb"

				$sImageMagickHome = "C:\ImageMagick"

				$sImageMagickConv = "$sImageMagickHome\convert.exe"

				New-Item -ItemType Directory -Force -Path $sOutputDir

				New-Item -ItemType Directory -Force -Path $sCharsDir

				New-Item -ItemType Directory -Force -Path $sCombDir

				Function outputPNG( $begin, $end, $font )
				{
					for ( $i = $begin; $i -le $end; $i++ )
					{
						$sCurChar = [char]::ConvertFromUtf32($i)
						
						If($sCurLabel -contains " ")
						{
						
						}
						ElseIf($sCurLabel -contains "")
						{
						
						}
						Else
						{
							If( Test-Path mychar.txt )
							{
								Remove-Item mychar.txt
							}
							
							Add-Content -Encoding UTF8 mychar.txt $sCurChar
							
							$sCurFileName = [string]"{0:X0000}" -f $i+".png"
							
							$sImageMagickArgs = @('-background', 'transparent', 
										'-fill', 'hsb(0,0,0)', 
										'-font', "$font",
										'-density','90',
										'-pointsize', '18',
										'-gravity', 'center',
										'label:@mychar.txt',
										"$sCharsDir\$sCurFileName")
											
							Write-Host $sImageMagickConv $sImageMagickArgs
							
							& $sImageMagickConv $sImageMagickArgs
						}
					}
				}

				outputPNG 0x0700 0x074F  "Unifont"  	#Syriac

I am trying to convert this Unicode range to images using this PowerShell script. I have tried a variety of different fonts and always for some reason there is an unwanted character coming out in the image which is output by the convert command. Sometimes this unwanted image is a ? which is placed directly to the left of the converting character which I can see very cleary. Sometimes this unwanted extra character is some form of background image that is coming in. I am attaching screenshot images.

https://onedrive.live.com/redir?resid=D ... =folder%2c

Thank you...
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting Syriac to an image.

Post by snibgo »

Does it work for low values of $begin and $end, eg 0 to 255?

You might try a hex dump of mychar.txt to ensure it contains valid UTF-8 characters, then check that your font has symbols for those characters.
snibgo's IM pages: im.snibgo.com
sepoto
Posts: 9
Joined: 2015-07-10T15:29:44-07:00
Authentication code: 1151

Re: Converting Syriac to an image.

Post by sepoto »

I have checked that the contents of the file used by the label parameter is correct and contains only one character by way of the PowerShell ISE. The fonts I have chosen from Wikipedia's Unicode font page as fonts supporting Syriac. I've noticed that this unwanted character is a persistent font issue with my script and if the font is not chosen perfectly then this unwanted character crops in. The project is available:

https://github.com/sepoto/powershell_font_to_texturemap

for anyone who wishes to try for themselves and currently I have not found a way to output a correct image for Syriac if this is known how to be done with ImageMagick.

Thank you...
sepoto
Posts: 9
Joined: 2015-07-10T15:29:44-07:00
Authentication code: 1151

Re: Converting Syriac to an image.

Post by sepoto »

The noto font kit from Google does the best job I can find with Syriac.
Post Reply