xulihang / ImageTrans-docs

Documentation of ImageTrans, a computer-aided image translation tool. ImageTrans的文档项目。ImageTrans是一款计算机辅助图片/漫画翻译软件。
https://imagetrans.readthedocs.io/
85 stars 9 forks source link

Make english translation visually good #190

Closed mspykerez closed 10 months ago

mspykerez commented 2 years ago

Is it possible to automatically detect and pass to the translation text the same font, size, color, style, etc of the RAW text even when it changes from page to page or in situations where the original image contains slight modifications between segments of text? I want to maintain the translated text as close as possible to the original format when using a machine translator.

The web extension ‘Raw Manga Fan’ seems to have it easy, it seamlessly makes the translated text visually nice, appealing immersive and can even keep different colors on the same text when they have a different color on the border all while maintaining the background color of the balloons whatever they may be.

xulihang commented 2 years ago

Could you give me an example?

mspykerez commented 2 years ago

Well it's pretty easy to find an image to test https://i.ibb.co/hm0VYKk/test.jpg

You can translate any image of any supported online site or load your own local ones with the LOCAL READER option that RMF has.

Mouseover the text to instantly switch from the translated text to the raw text and see how it differs. It's not 100% perfect but it's close. The downside is that atm you can't save the translated images to your computer.

Also https://github.com/zyddnys/manga-image-translator should work just fine but for some reason atm it only works with languages that support vertical text which unfortunately makes english not an appealing option.

xulihang commented 2 years ago

Raw Manga Fan uses a fixed stroked font style. Manga-image-translator can detect the color and rotation. ImageTrans can also detect background and font colors, but it has to be invoked manually.

ImageTrans is for general purpose. Users have to set up the font styles for their use cases.

For the image you gave, you can do the following to optimize the result.

  1. In project settings, make the mask dilation kernel size bigger to better remove text.
  2. Set up a default font style: stroked, vertical centered, capital-case.

image

Result:

Default font style:

test

Specified font style:

test

What is lacking right now is that the words are wrapped because the original width is too small since the Japanese are vertically arranged.

mspykerez commented 2 years ago

The default style is awful indeed!

Can't you make it use better settings by default OR auto-detect the best settings according to a given image instead of making the user manually input everything?

And ye some words get cut off to another line even after you manually 'optimize' the results which is a bummer. There should be some 'logic' you could implement to just prevent the words from being cut off. I think that it would be preferable to not have a word cut off even if the means they will show slightly out of position.

Many people just want a quick and nice painless way to translate and save the images and I feel that ImageTrans is getting more bloated by the day which can make it intimidating to use. Making it more user-friendly and straightforward automatically decide for you would be a godsend.

A mode where it will just detect the original image settings and change it dynamically from image to image to match the original would be great especially when batch translating, at least this way the original image text style would be preserved for the better or the worst and if the user doesn't like a particular style he could beforehand just create an 1-time sort of 'blacklist' to prevent said style of ever being used and present an alternative for it.

Now that I'm thinking about it perhaps would be a good idea to have different user profiles and import/export share them with other people.

xulihang commented 2 years ago

original image text style would be preserved

This is not an accurate expression. The target text style will not be all the same.

make it use better settings by default

What looks good to you may not be good to others. But providing some preset styles for different target languages and use cases may be a good idea.

user profiles and import/export share them

We can just share a template project file. The font styles can also be imported from other project files.

image

intimidating to use

ImageTrans is a computer-aided translation tool. The more manual adjustments available, the better for its target users. If users just need to read, raw manga fan is more convenient.

mspykerez commented 2 years ago

I'm not advocating to get rid of the neat features that ImageTrans has!

The automated tools that ImageTrans provides are great for doing and editing translations by hand for semi-professinal users but at the same time I wish that it was also more noob friendly in a way that people could just load up all the RAW images they want and press a button to let ImageTrans do all the work automatically for them which includes figuring out by itself the best style for each image and so on... just let it work and save the images to the computer so later one could just read all the manga that was machine-translated by ImageTrans with close to none user intervention with a manga reader of choice whether we are online or not. Basically an 'easy mode' which I know will not be perfect and nowhere near to when people manually adjust the settings but just good enough, and when I say 'good enough' surely it can be better than the default style used on the image posted above.

I think you'd gain way more users if that was the case.

xulihang commented 2 years ago

The silent translator and the server version can be seen as an easy mode. Users just need to select which language to translate into and then they can get the translated image.

Hosting a server myself saves users from the fuss of setting up their own environment. But a server is costly, so I haven't provided such an option.

mspykerez commented 2 years ago

I don't mind doing a 1 time configuration setup of ImageTrans and have all the workload done on my computer even if it would take more time (in fact I'd prefer not to rely on external servers), as long that from there on forward ImageTrans would pick and choose the best suited settings dynamically for the target language which I imagine would vary according to the different styles of the raw images it detects and if not possible to do so at least fall back to a better default style that would suffice for most cases which atm as per the image shown in the example above is not that good without manually adjusting the settings (the style used by RMF looks to be a good default style to consider when translating into english is concerned).

More importantly the words being cut off in the middle to the next line when MTL to english is really a big let down. I think that people who do not wish or have time to do any manual adjustments would prefer having the full word show a little outside the original manga space/balloon/bubble or whatever shape like we usually see RMF doing vs having it cut off which as an english reader can be so unappealing and confusing.

Speaking for myself I just want a full auto mode to process and MTL different mangas while visually maintaining good quality standards without much user intervention for batch translating and consequently save the images to the computer in order to read them at any time with my favorite manga reader without expecting it to be a 100% accurate translation but rather understandable and nice to look at.

In any case thanks for all the effort you put into this app.

xulihang commented 2 years ago

About words being cut into different lines, this is related to JavaFX's TextFlow (repo). I cannot do much about this unless I make my own text engine.

mspykerez commented 2 years ago

About words being cut into different lines, this is related to JavaFX's TextFlow (repo). I cannot do much about this unless I make my own text engine.

That's sad news, to me this problem is even bigger than having bad looking font styles by default. I was hoping you could do something about it because looking at RMF it doesn't look like it has the issue... probably because RMF approaches it on a different way than ImageTrans I really dunno.

xulihang commented 2 years ago

RMF uses web technologies which is much easier to layout text using CSS, and it manages to measure the suitable font size which works quite well.

xulihang commented 2 years ago

I've managed to find a workaround for this.

As long as the text box has a suitable width/height ratio, the words will not be cut.

https://user-images.githubusercontent.com/5462205/164878829-a65f80fd-be8c-4ee9-a8f9-4897aed6cd9b.mp4

Code behind:

If height>width*2.5 Then
    Dim newWidth As Int = width*1.8
    Dim newHeight As Int = newWidth*0.6
    Dim offsetX As Int = (newWidth - width)/2
    Dim offsetY As Int = (height - newHeight)/2
    X= X - offsetX
    width = newWidth
    Y = Y + offsetY
    height = newHeight
End If
xulihang commented 2 years ago

About default fonts, fonts like wild words cannot be used for commercial use. I don't think I can package it with ImageTrans.

mspykerez commented 2 years ago

I've managed to find a workaround for this.

That's good! I suggest making it the default behavior when using MTL on languages that are horizontal by nature.

Btw you say that ''as long as the text box has a suitable width/height ratio'' does this mean it will not always work? If so why not just automatically calculate some extra width/height just in case, even if that means getting some words outside the bubbles, granted that I'm not sure if ImageTrans would be able to tell on its own if it doesn't give additional width/height we would end up with words being cut off meaning that theoretically it could give extra space in situations where it is not needed and make it look worse...

About default fonts, fonts like wild words cannot be used for commercial use. I don't think I can package it with ImageTrans.

Does this include the font used by RMF? In any case you can just link to them and make it easy to install separately which would be a worthy extra step for the user to take!

Thx for giving the English auto translations some love!

xulihang commented 2 years ago

I've given the code.

If the height > width*percent and the target text direction is horizontal, then the program will automatically change the ratio to a fixed value which is 5/3. This works in most cases as long as there is not a very long word.

xulihang commented 2 years ago

The function mentioned above, which makes vertical text areas horizontal, is added in v1.6.5.

xulihang commented 5 months ago

In v2.12.0, the typesetting for English has been improved with the "do not break words" project settings.

It can calculate the suitable font size and width for the text boxes to beatifuly display English.

image

image

xulihang commented 5 months ago

A detailed guide for lettering: https://www.basiccat.org/lettering-guide-for-Japanese-English-manga-translation/