Hardocs / desktop-app

Hardocs desktop app presenting current docs editing functionalities.
GNU General Public License v2.0
3 stars 2 forks source link

Processing images including downloading, downsizing and serving them #19

Open jurra opened 3 years ago

jurra commented 3 years ago

Feature description and scenario

Feature

How to implement it

I prefer option 1 but we should talk about it.

Image specifications defined by @narration-sd

Special considerations for Images

-The Finder view would be much faster, as it's just metadata and one pic per project shown.

jurra commented 3 years ago

Clive @narration-sd idea about handling image, reduce them before saving to file, in the context of html lingua franca. Issues:

jurra commented 3 years ago

Here is the link with the last session @DNature and I had about dealing with images to downsize them and download them. image

narration-sd commented 3 years ago

Good to see this, and as in the writings with Divine, I've felt a little hazy up to now about the full result of normalized (let's use that word, normalized for our needs) images.

Looking at your diagram, it may be that it's just fine and complete to consider them only inside the fully processed html lngua franca doc instance -- and only ever save that to the Hardocs-Summary project file folder.

That way we will not interfere with whatever they have.

And maybe because of this as well as other considerations, there's a strong argument that we never offer to convert back to any of their other formats. Thus conversion from Word, MD, etc., is only ever one-way: we import.

This would satisfy in many ways, and much avoid pitfalls. Can we think to set that in proper stone, from now?

It seems this would radically decrease my problematic intuitions about the area -- properly as well our actual work...

...p.s...showing how this noted conversation method can actually help us....too

jurra commented 3 years ago

Some references I found that can help solving this problem:

DNature commented 3 years ago

Great reference Jose. However, How do we continuously display an image if we have to go through these process. The ways i can think of this to work like when a user drops and image, paste an image or use the regular markdown image are:

jurra commented 3 years ago

I would go for the second approach @DNature, as you mentioned before there myght be a jumping behaviour if we return a promise handling the image upload. We could do something like github does also as you say where you just write on the html uploading image, until it returns the new minimized image.

narration-sd commented 3 years ago

I may be missing something here, but I had some further thought after @DNature and I worked over this area yesterday. Let's see if it helps...

(Hardocs Object is the one that mirrors the shape of the CombatCovid/Hardocs filesystem structure, in the diagram I made recently)

2) I see Markdown still being mentioned. But we are making an HTML editor. Markdown would be brought in by pandoc conversion, which with the flags I;'ve showed will already have converted any images to base64 internal. We might still have to decode, convert to jpeg, recode, if the tag indicates they are png -- very important!! Or any other oversized format. Easy to tell by that visible tag.

3) Now, consider our HTML editor (CKEditor). There are a number of ways someone might edit in an image. They could write HTML tags, they could (perhaps) insert a file from their laptop filesystem, or they could drag-drop an image from another source like a web browser. I consider that whatever they do, a) this should not matter b) it's a very over-complex and thus bad idea to consider interfering in CKEditor's operation by any kind of hooks. Just leave the image in the form as they placed it alone, much smarter, no?

4) How we get to do that (leave it alone) is that we only (and definitely always) do all our discovery of images and conversions only at the point of pulling the new or modified, edited HTML document into our Hardocs Data Object. Thus it is a regular processing we always do over the html document, before it is written to the Data Object.

5) Only after that processing over the html document is done, every time (on a 'save', for example, from the editor), do we actually add or replace the lingua franca, fully processed images html document into its place in the data object tree.

6) With all steps completed, the Hardocs Data Object is now clean, and can be placed/replaced in the Vuex, for display, for pushing to cloud or browser database via Habitat call, or emitted to the filesystem for our representation there.

I think the above makes everything quite straight forward, and allows the Image Processing to be...a process, with nicely defined steps of its own to a) retrieve from net via fetch b) convert to jpeg if needed, even if it's already base64, probably next c) resize so it's within the boundaries I put the calculation for in the paper under architecture, d) final conversion to base64 , and finallyl e) replace the element in the html doc so that it's using the base64,

Seems this will be nice to work up, and will nicely get us there, no? Thanks, guys.

jurra commented 3 years ago

I agree with most of it @narration-sd , Except with point 2:

  1. I see Markdown still being mentioned. But we are making an HTML editor. Markdown would be brought in by pandoc conversion, which with the flags I;'ve showed will already have converted any images to base64 internal. We might still have to decode, convert to jpeg, recode, if the tag indicates they are png -- very important!! Or any other oversized format. Easy to tell by that visible tag.

Having a straightforward conversion into markdown, provides portability and mobility to the folder with docs markdowns. They could be done with pandocs also, but it requires setting up pandocs etc. CkEditor also outputs markdown by the way.

The main issue related to markdown is not so much pandocs or the conversion itself (CKeditor also outputs markdown). The issue is more of replacing the paths in th converted mardkown into te relative images paths in the hardocs folder. For me as a user it would be also great to have the downsized files in the folder. Because then I can upload that little folder into thingiverse, github, or other hosting services and people can still read the documents without having to depend on hardocs.

narration-sd commented 3 years ago

Well, that's kind of the whole point -- by centering on the Hardocs Object, and guaranteeing any image processing is done by the time it's released to cloud, browser, or filesystem, you have a central point of truth.

It seems your hanging onto CKEditor writing Markdown itself is what may be occluding this view??

If you somehow have to have that (why?, but) you could pull the Hardocs Object result back into ckeditor...then save out MD from there.

It feels like very complicated even for the user to have to think about Markdown at that point, though, and remember, it is going to be the definite minority who want to have anything to do with Markdown at all,, in the real user community we expect, no?

jurra commented 3 years ago

I agree with the central point of truth, as long as the markdowns are exported builds, (an output that you can generate from the main source of truth), I think is all good ;)

Maker communities and hardware developers, specially those that do electronics and coding are quite familiar with markdown and github. Also scientists that use jupyter notebooks and github. So it varies on the audience and also the generations.

narration-sd commented 3 years ago

And, we got a great agreement -- and a diagram -- on how this gets arranged and done.

I'll share what I think as a link, and you can discuss it with Jose, @DNature -- will be good.

Not entirely visible in it is a quite important thing we 'hashed out' -- that at the time the Image Processing occurs, also, each image of an html lingua franca document, after processing (and even if we didn't have to modify it) ,is also dumped out to the filesystem under /imgs -- and the same, added into the imgs component of the Hardocs Data Object to match, so that those images are all available for other uses.

We would solve the problem if it occurs of llmiting which images to actually see in UX by adding later some kind of flag to the component for each img in the object - JSON makes this straightforwards, not to be worked with now in our release preparation.

narration-sd commented 3 years ago

Here's the diagram, at least a version that's useful -- Jose will put it into Google folder in some form am sure: https://app.diagrams.net/#G1l9TruQ5JMGVGhOJFXXASFIACaV1OoTYa

jurra commented 3 years ago

Here is the document in the google drive addressing image challenges and ideas. (Read the section special considerations for images)

jurra commented 3 years ago

@DNature has managed to process images in html and make them smaller. Maximum quality 600pixels. Currently also the img src attribute is replaced by an image path.(which is not working)

Minimum requirement for the images

Another ancillary requirement