Add script to convert images from images to out folder#30
Add script to convert images from images to out folder#30Genne23v wants to merge 1 commit intoSeneca-CDOT:mainfrom
Conversation
As I understood the flow of the events, it's as follows:
|
|
Thanks for the comment @SerpentBytes. I'm still not sure how it is deployed to GitHub Pages, but let me start writing scripts. |
|
@SerpentBytes Just to make sure I'm on the right track. My understanding is that the user go to |
To access the service, the user needs to go through the authentication which we are doing using a form which accepts PAT token and |
|
@Genne23v At the moment, only authentication and repo generation functionality is implemented. We have a UI for uploading photos, but it's not connected to the service. |
|
We have a few options we can take here:
Regardless of which way we go, I think you should consider the file types and sizes to generate. You're picking a few sizes, but they are quite small, and they include both a width and height. This will skew images that don't have the same aspect ratio as your final dimensions. We should probably use the I also think we need more than WebP. Probably we should do: JPEG, WebP, AVIF, PNG. RE: your code, you are mixing async, sync fs methods. I would use async everywhere or promises. |
|
Thank you for the feedback. I'm combining UI and GitHub repo generation script along with image optimizer. So I will replace server-side image generation work with your suggestion. Basically my change will do
Please let me have any advise if you have. Thank you! |
|
I think this sounds right, yes. Our UI will have a bunch of work to do, so we'll need "progress" indication to be part of it, so people don't close the window. |
|
@humphd @SerpentBytes
Please try the feature and let me know if there is any improvement that I need to make. Thanks |
|
Also I noticed there is a merge conflict. It seems like I don't have an authority to fix this. Please let me know if I need to do something. |
|
@humphd I have updated |
|
@SerpentBytes As I mentioned above, I copied |
|
@Genne23v Make sure to update the |
|
I added your incremental |
humphd
left a comment
There was a problem hiding this comment.
This is awesome, nice work! A few comments.
src/UploadInterface.js
Outdated
| <div className="App"> | ||
| <header className="preview"> | ||
| {!userMessage ? ( | ||
| <></> |
There was a problem hiding this comment.
null is more common when you want to show nothing.
| }; | ||
| reader.readAsDataURL(file); | ||
| imgPreviewEl.current.title = file.name; | ||
| reader.readAsDataURL(files[0]); |
There was a problem hiding this comment.
Question: on line 137 you allow selecting multiple files, but here assume it's only 1 (i.e., files[0]). Should you be looping through them?
There was a problem hiding this comment.
If I understand this code correctly, it should read only one image and add it to imgPreviewEl.current.src to load the image on the element. If I change it to files, it doesn't load the preview on the element. I think it doesn't need to read every file unless if we want to show multiple previews.
src/worker/functions/commit-files.js
Outdated
| reader.onload = async () => { | ||
| const imageBuffer = reader.result; | ||
| const byteArray = new Uint8Array(imageBuffer); | ||
| const blob = new Blob([byteArray]); |
There was a problem hiding this comment.
Since you know the file types we allow (i.e., image/*), why don't we pass the mimeType here too as second arg: https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob
| const imageBuffer = reader.result; | ||
| const byteArray = new Uint8Array(imageBuffer); | ||
| const blob = new Blob([byteArray]); | ||
| const BlobURL = URL.createObjectURL(blob); |
There was a problem hiding this comment.
lowerCamelCase for naming in JS
src/worker/functions/commit-files.js
Outdated
| const byteArray = new Uint8Array(imageBuffer); | ||
| const blob = new Blob([byteArray]); | ||
| const BlobURL = URL.createObjectURL(blob); | ||
| const blobData = octokit.request(`POST /repos/${username}/${repoName}/git/blobs`, { |
There was a problem hiding this comment.
Either you need to await this call, or better, you should return it as the Promise to wait on in line 48 below.
|
This needs a rebase too. |
I rebased my branch and it shows one commit in my view. Also I will make sure there is one commit in next one. Please let me know something is still not right. Thanks |
|
@humphd I have added |
This PR is addressing #3.
I'm adding
image-optimizer.jswith this PR. But I think it will need much more discussion from here as I have some questions about the next step.imagesfolder and create resized images inoutfolder.525 x 295,746 x 420,934 x 525. Please let me know if this is suitable. Probably I have to create more square-like images for image grid layout.sharplibrary, it will clear most of metadata, but let me know if this is not the intention.node image-optimizer.js.