Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on lemmy.world

4 replies

lemmy.world

I'm trying to get the generated image's source automatically and use it elsewhere in my perchance generator but I can't seem to find a good method to do this. I know the resulting image that I want the source from has the id resultImgE1, I know the id of its container, and I know its in an iframe, like the rest of my html code. I get a lot of errors when I try ChatGPT's methods, even if I tweak them. Let me know if anyone has tried this, or if there's a post about this already on here.

1
lemmy.world

After a long while of troubleshooting and trying to understand how the generation system works I've come to the conclusion that it is currently not possible to do what I set out to do. I would have to be able to request the image with a post request but I can't due to security stuff, or I would have to read the url of the image on the website which doesn't work because trying to access a cross-origin frame is bad ig. (Just saw there was another post addressing this).

1
perchancereply
lemmy.world

I think these examples are what you're looking for?

Also, the iframe has a property iframe.textToImagePluginOutput which is added after the generation is finished, and you can use that to access the image either as a HTML5 canvas or as a Data URL:

iframe.textToImagePluginOutput.canvas
iframe.textToImagePluginOutput.dataUrl
5

You reached the end