-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add script to convert images from images to out folder #30
base: main
Are you sure you want to change the base?
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome, nice work! A few comments.
src/UploadInterface.js
Outdated
return ( | ||
<div className="App"> | ||
<header className="preview"> | ||
{!userMessage ? ( | ||
<></> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null
is more common when you want to show nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be addressed
const reader = new FileReader(); | ||
reader.onload = (e) => { | ||
imgPreviewEl.current.src = e.target.result; | ||
}; | ||
reader.readAsDataURL(file); | ||
imgPreviewEl.current.title = file.name; | ||
reader.readAsDataURL(files[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be addressed accordingly
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lowerCamelCase for naming in JS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be handled
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either you need to await
this call, or better, you should return it as the Promise to wait on in line 48 below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be addressed
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.js
with this PR. But I think it will need much more discussion from here as I have some questions about the next step.images
folder and create resized images inout
folder.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.sharp
library, it will clear most of metadata, but let me know if this is not the intention.node image-optimizer.js
.