mirror of
https://github.com/anatolykopyl/vk-nft-feed.git
synced 2026-03-26 04:44:34 +00:00
Lite version: just uploads images without creating svgs
This commit is contained in:
@@ -22,7 +22,7 @@ export default async function(owner_id) {
|
||||
let images = [];
|
||||
|
||||
for (const post of posts) {
|
||||
images.push(await postToImage(post));
|
||||
images.push(...postToImage(post));
|
||||
}
|
||||
|
||||
return images;
|
||||
|
||||
4
index.js
4
index.js
@@ -11,12 +11,12 @@ const entity = process.argv[2];
|
||||
await rarepress.init({ host: "https://rinkeby-beta.rarepress.org/v1" });
|
||||
|
||||
(await getImages(entity)).forEach(async (image, index) => {
|
||||
const cid = await rarepress.fs.add(Buffer.from(image));
|
||||
const cid = await rarepress.fs.add(image);
|
||||
const token = await rarepress.token.create({
|
||||
type: "ERC721",
|
||||
metadata: {
|
||||
name: `${index}`,
|
||||
description: `${index}.svg`,
|
||||
description: `Picture #${index}`,
|
||||
image: `/ipfs/${cid}`,
|
||||
},
|
||||
});
|
||||
|
||||
2872
package-lock.json
generated
2872
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -10,12 +10,9 @@
|
||||
"author": "Anatoly Kopyl",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@svgdotjs/svg.js": "^3.1.1",
|
||||
"axios": "^0.25.0",
|
||||
"dotenv": "^14.2.0",
|
||||
"progress": "^2.0.3",
|
||||
"rareterm.node": "^0.0.10",
|
||||
"sharp": "^0.29.3",
|
||||
"svgdom": "^0.1.10"
|
||||
"rareterm.node": "^0.0.10"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,11 @@
|
||||
import {createSVGWindow} from 'svgdom';
|
||||
import {SVG, registerWindow} from '@svgdotjs/svg.js';
|
||||
// import sharp from 'sharp';
|
||||
|
||||
function makeSvg(images) {
|
||||
const spacing = 50;
|
||||
const height = images.length * (900 + spacing) + spacing;
|
||||
|
||||
const window = createSVGWindow();
|
||||
const document = window.document;
|
||||
registerWindow(window, document);
|
||||
|
||||
const draw = SVG(document.documentElement).width(1000).height(height);
|
||||
draw.rect(1000, height).fill('white');
|
||||
images.forEach((image, i) => {
|
||||
const y = 50 + i * (900 + spacing);
|
||||
draw.image(image.url).x(50).y(y).width(900).height(900)
|
||||
});
|
||||
|
||||
return draw.svg();
|
||||
}
|
||||
|
||||
// function svgToPng(svg) {
|
||||
// return sharp(Buffer.from(svg)).toBuffer();
|
||||
// }
|
||||
|
||||
export default function(post) {
|
||||
const photoAttachments = post.attachments.filter((attachment) => {
|
||||
return attachment.photo;
|
||||
})
|
||||
|
||||
const images = photoAttachments.map((attachment) => {
|
||||
return {
|
||||
url: attachment.photo.sizes[attachment.photo.sizes.length - 1].url,
|
||||
};
|
||||
});
|
||||
const images = photoAttachments.map((attachment) =>
|
||||
attachment.photo.sizes[attachment.photo.sizes.length - 1].url
|
||||
);
|
||||
|
||||
return makeSvg(images);
|
||||
return images;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user