Skip to content
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

Create images.js #92

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft

Conversation

AlphaTechNinja
Copy link

@AlphaTechNinja AlphaTechNinja commented Dec 26, 2023

this is my image manipulating library

images

description

this library is used to manipulate different types of images including pngs, jpegs, and svg

features

allows writing and reading data from an image
allows creating and importing images as well as exporting (svg is not allowed as it would not make sense mostly because of writing pixels makes rectangles so the data would be really long)

notes

bitmap and svg are currently not supported (even though I added bitmap it doesn't work)

updates

might add common svg functions (aka drawing strokes and shapes)

Next thing to add is cropping and resizing (possibly rotating)

Copy link

vercel bot commented Dec 26, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
penguinmod-extensions-gallery ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 13, 2024 5:31pm

@AlphaTechNinja
Copy link
Author

forgot to add this extension doesn't need to be unsandboxed

@AlphaTechNinja
Copy link
Author

@SharkPool-SP , @TheShovel , @JeremyGamer13 .Can someone review my extension?, it has been about a week.

@RedMan13
Copy link
Contributor

boowomp

@SharkPool-SP
Copy link
Collaborator

@SharkPool-SP , @TheShovel , @JeremyGamer13 .Can someone review my extension?, it has been about a week.

Don't rush stuff. Give it time

@SharkPool-SP
Copy link
Collaborator

You need to add an extension thumbnail and edit the extension.js file to include ur extension. Please do it in this pr and not separate ones.

@RedMan13
Copy link
Contributor

you infact do not need to do that and instead just have us do it for you although it wouldnt be bad for you to add it on your own :bleh

@AlphaTechNinja
Copy link
Author

You need to add an extension thumbnail and edit the extension.js file to include ur extension. Please do it in this pr and not separate ones.

I thought the thumbnail / banner was optional... anyways I can create a thumbnail if needed

@RedMan13
Copy link
Contributor

...it is optional

@AlphaTechNinja
Copy link
Author

Also the reason I asked is because most of the extensions got reviewed in less than a week

@RedMan13
Copy link
Contributor

idk

@RedMan13
Copy link
Contributor

seems like its more usefull as an image converter then just general image work in its current state

@AlphaTechNinja
Copy link
Author

Ok I’m probably just gonna close this and add all the features like svg. it’s name is images because it isn’t specifically for modifying images but it is one of the key features

Added “images” extension
@AlphaTechNinja
Copy link
Author

@SharkPool-SP , @RedMan13 . I am gonna add it to the website so I can see the preview (:

@SharkPool-SP
Copy link
Collaborator

...it is optional

Yeah but it will look like shit without it 🤷‍♂️

@RedMan13
Copy link
Contributor

...it is optional

Yeah but it will look like shit without it 🤷‍♂️

still optional

@AlphaTechNinja
Copy link
Author

what is that thing

The extension?

@JeremyGamer13
Copy link
Member

sorry that this was abandoned for a while

  • the defaultValue for import image is way too long, just make it data: to entail a data url should be there
  • certain blocks tell you that an image isnt selected as an error, but some like export image just throw a canvas error instead
  • blocks like import image dont wait for the importing to finish, which could cause timing problems

half of fix will fix later
@AlphaTechNinja
Copy link
Author

sorry that this was abandoned for a while

  • the defaultValue for import image is way too long, just make it data: to entail a data url should be there
  • certain blocks tell you that an image isnt selected as an error, but some like export image just throw a canvas error instead
  • blocks like import image dont wait for the importing to finish, which could cause timing problems

I am currently working on fixing this and I have a question, instead of erroring what do you want it to do (right now I'm making it return -1 on anything that has a return)

@RedMan13
Copy link
Contributor

i would think detect the error then either throw a new error to the user that actually states whats wrong or eat the error and act as if nothing is wrong

instead of throwing errors when we go to an invalid index return -1
@AlphaTechNinja
Copy link
Author

another option I was considering was adding new blocks called hasErrored and errorMessage but for now it spits out -1 on any block that returns a value. I'm currently working on making import run async so it halts the current script

@AlphaTechNinja
Copy link
Author

sorry that this was abandoned for a while

  • the defaultValue for import image is way too long, just make it data: to entail a data url should be there
  • certain blocks tell you that an image isnt selected as an error, but some like export image just throw a canvas error instead
  • blocks like import image dont wait for the importing to finish, which could cause timing problems

also import takes a data uri and sets a new image's source to it so I don't see how to make setting a value async

hopefully fixed the import function
i forgot something
I'm so sorry for changing this so many times I had to reread the documentation on how to use promises with Turbowarp and PenguinMod extensions.
@AlphaTechNinja
Copy link
Author

new Promise((resolve, reject) => {
    const image = new Image()
    image.onload = () => resolve(image)
    image.onerror = reject
    image.src = 'src url'
})

penguinmod seems to not add the image to the list so I will try something else (btw I'm still trying this snippet first)

attempting to fix it with RedMan13's idea
@AlphaTechNinja
Copy link
Author

aha I see to make it work I should put a blank data uri instead of nothing (I really hope this works)

might be fixed
@AlphaTechNinja
Copy link
Author

might have to scrap the promise idea as it seems to not want to save the image to the saved JSON table in PenguinMod

@RedMan13
Copy link
Contributor

new Promise((resolve, reject) => {
    const image = new Image()
    image.onload = () => resolve(image)
    image.onerror = reject
    image.src = 'src url'
})

penguinmod seems to not add the image to the list so I will try something else (btw I'm still trying this snippet first)

wadya mean

@AlphaTechNinja
Copy link
Author

new Promise((resolve, reject) => {
    const image = new Image()
    image.onload = () => resolve(image)
    image.onerror = reject
    image.src = 'src url'
})

penguinmod seems to not add the image to the list so I will try something else (btw I'm still trying this snippet first)

wadya mean

I mean it doesn't register it into the saved list of images

@RedMan13
Copy link
Contributor

the code you quoted was never meant to?

Scraped promise system for import image
@AlphaTechNinja
Copy link
Author

the code you quoted was never meant to?

what's happening is I have it to where it adds the image to the saved list but for some reason, it doesn't add it.
this is the code chunk of what I wrote (using your promise idea)

let image = new Image();
saved[name] = image;
return new Promise((resolve, reject) => {
      image.onload = resolve;
      image.onerror = reject;
      image.src = uri;
});

@AlphaTechNinja
Copy link
Author

I might try making an image using the document but I don't think that will make a difference.

@RedMan13
Copy link
Contributor

what do you mean "doesnt add it", because thats just not true taken literally, the item gets added to the saved object in the code you provided

@RedMan13
Copy link
Contributor

image

@AlphaTechNinja
Copy link
Author

uri and name exists in the arguments passed to the block. saved is global in the extension so you can never test it without running the extension with the code if you want to try it maybe download it, modify it, and try it on PenguinMod/TurboWarp

@RedMan13
Copy link
Contributor

uri and name exists in the arguments passed to the block. saved is global in the extension so you can never test it without running the extension with the code if you want to try it maybe download it, modify it, and try it on PenguinMod/TurboWarp

what you said makes no sense. all i did was fabricate an instance for the code that was inside the block that works as the block inteads it to work

fixed the `writePixel` offset so that it is aligned to top-left
@SharkPool-SP
Copy link
Collaborator

Marking as a draft due:
-to Conflicts with other files
-lack of updates/commits from creator

@RedMan13
Copy link
Contributor

i mean if its finnished you wouldnt update it right :trollface:

@SharkPool-SP
Copy link
Collaborator

i mean if its finnished you wouldnt update it right :trollface:

its not though. There are still unsolved issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants