heat_at_pointmain.tsx6 matches
13// Load our data tile from url, arraybuffer, or blob, so we can work with it:
14const tiff = await fromUrl("https://www.wpc.ncep.noaa.gov/heatrisk/data/HeatRisk_1_Mercator.tif");
15const image = await tiff.getImage(); // by default, the first image is read.
1617// Convert a GPS coordinate to a pixel coordinate in our tile:
1819const bbox = image.getBoundingBox();
20const pixelWidth = image.getWidth();
21const pixelHeight = image.getHeight();
22const bboxWidth = bbox[2] - bbox[0];
23const bboxHeight = bbox[3] - bbox[1];
3536const window = [xPx, yPx, xPx + 1, yPx + 1];
37const data = await image.readRasters({ window });
3839console.log(data);
4041// const rasters = await image.readRasters();
42// const { width, height, [0]: raster } = rasters;
43
vtApiTypesmain.tsx1 match
668bio?: string | null;
669/** @description The url for the user's profile picture */
670profileImageUrl?: string | null;
671}) & components["schemas"]["Author"];
672BaseVal: {
1213// INST: Add these keys in val env variables
14// NOTE: the image notes don't work at the moment, and if you add a image note,
15// the task is skipped
1622var add_to_habitify_todoist_project_id = "XXXX"; // INST: Project ID goes here
23var todoist_dict_mapping = { // Note: You can choose to leave this dict empty and it will still work
24"Image Notes": { // This is for a section that is image notes only for any habit without adding a log
25"todoist-section-id": "XXXX", // INST: section id for just image notes section goes here
26"habitify-area-name": "undefined", // keep this value as undefined
27specialPrompt: "only_image", // keep the value as only_image
28},
29"Text Notes": { // This is for a section that is text notes only for any habit without adding a log
30"habitify-area-name": "undefined", // keep this value as undefined
31"todoist-section-id": "XXXX", // INST: section id for just image notes section goes here
32specialPrompt: "only_text", // keep the value as only_text
33},
115}
116117async function resizeAndConvertImage(imageBuffer) {
118try {
119const image = await Jimp.read(imageBuffer);
120const resizedImage = await image.resize(800, 800, Jimp.RESIZE_BILINEAR);
121const jpegBuffer = await resizedImage.quality(80).getBufferAsync(Jimp.MIME_JPEG);
122123if (jpegBuffer.length >= 2000000) {
124console.error("Error: Resized image size should be smaller than 2MB");
125return null;
126}
128return jpegBuffer;
129} catch (error) {
130console.error("Error processing image:", error);
131return null;
132}
133}
134135async function downloadImage(url) {
136try {
137const response = await fetch(url, {
144}
145146const imageBuffer = await response.buffer();
147const resizedImageBuffer = await resizeAndConvertImage(imageBuffer);
148149return resizedImageBuffer;
150} catch (error) {
151console.error("Error downloading or processing image:", error);
152return null;
153}
227let habitSchema;
228229if (specialPrompt === "only_text" || specialPrompt === "only_image") {
230habitSchema = z.object({
231name: z.enum(habitKeys),
264prompt += "The habits you can choose from are: " + habitKeys_str + ".\n";
265266if (specialPrompt === "only_image" || specialPrompt === "only_text") {
267prompt +=
268"You are extracting the name of the habit, the date of the habit (if mentioned, or otherwise an empty string), and any note if it exists about a habit (if mentioned, or otherwise an empty string). Remember, a note is associated with only 1 habit and will say 'note that' or something like that.\n";
365}
366367async function addImageNote(habit_id, created_at, imageBuffer) {
368const url = `https://api.habitify.me/notes/addImageNote/${habit_id}?created_at=${encodeURIComponent(created_at)}`;
369const headers = {
370Authorization: HABITIFY_API_KEY,
371"Content-Type": "image/jpeg",
372};
373376method: "POST",
377headers: headers,
378body: imageBuffer,
379});
380if (!response.ok) {
462for (const task of tasks) {
463console.log(task);
464task.imageComments = null;
465if (task.commentCount > 0) {
466const imageComments = [];
467const todoist_comments = await getCommentsForTask(task.id);
468for (const comment of todoist_comments) {
469// console.log(comment);
470if (comment.attachment && comment.attachment.resourceType === "image") {
471const imageBuffer = await downloadImage(comment.attachment.image);
472if (imageBuffer) {
473imageComments.push(imageBuffer);
474}
475}
476}
477task.imageComments = imageComments ? imageComments : null;
478}
479480/// START---REMOVE ONCE UPLOAD IS FIXED
481if (task.imageComments) {
482continue;
483}
499console.log(habits);
500for (const habit of habits) {
501if (specialPrompt != "only_image" || specialPrompt != "only_text") {
502await addLog(
503habits_list[habitifyAreaName][habit.name].id,
510await addTextNote(habits_list[habitifyAreaName][habit.name].id, habit.date, habit.note);
511}
512if (task.imageComments) {
513for (const imageComment of task.imageComments) {
514await addImageNote(
515habits_list[habitifyAreaName][habit.name].id,
516habit.date,
517imageComment,
518);
519}
resumeConfigmain.tsx1 match
19"name": "Thomas Davis",
20"label": "Web Developer",
21"image": "https://avatars0.githubusercontent.com/u/416209?s=460&u=38f220a2c9c658141804f881c334c594eb1642ac&v=4",
22"summary":
23"I'm a full stack web developer who can build apps from the ground up. I've worked mostly at startups so I am used to wearing many hats. I am a very product focused developer who prioritizes user feedback first and foremost. I'm generally very flexible when investigating new roles. ",
modifyImagemain.tsx6 matches
1import { ImageMagick, initializeImageMagick, MagickGeometry } from "https://deno.land/x/imagemagick_deno@0.0.14/mod.ts";
23export async function modifyImage(
4input: Uint8Array | "logo:",
5) {
6return new Promise<File>((resolve) => {
7ImageMagick.read(input, (image) => {
8image.trim();
9image.repage();
10image.write((data) => resolve(new File([data], "logo.png", { type: "image/png" })));
11});
12});
modifyImageREADME.md2 matches
1Code from https://deno.com/blog/build-image-resizing-api
23Useful for compressing an image before sending to chatgpt4v, for example
imageMagickWasmExamplemain.tsx11 matches
1import {
2ImageMagick,
3initializeImageMagick,
4Magick,
5MagickFormat,
6Quantum,
7} from "https://esm.sh/@imagemagick/magick-wasm";
89const resp = await fetch("https://esm.sh/@imagemagick/magick-wasm@0.0.29/dist/magick.wasm");
10const wasmBytes = await resp.arrayBuffer();
1112initializeImageMagick(wasmBytes).then(() => {
13console.log(Magick.imageMagickVersion);
14console.log("Delegates:", Magick.delegates);
15console.log("Features:", Magick.features);
1718console.log("");
19ImageMagick.read("logo:", image => {
20image.resize(100, 100);
21image.blur(1, 5);
22console.log(image.toString());
2324image.write(MagickFormat.Jpeg, data => {
25console.log(data.length);
26});
23"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" ",
24),
25{ headers: { "Content-Type": "image/svg+xml" } },
26);
27}
14};
1516const promptKey = 'imagePromptValue';
1718export function updateForm() {
4546const model = document.getElementById('model').value;
47const imageSize = document.getElementById('image_size')?.value;
48const prompt = document.getElementById('prompt').value;
4959loadingShimmer.className = 'loading-shimmer';
6061const imageFooter = document.createElement('div');
62imageFooter.className = 'image-footer';
6364const modelElement = document.createElement('p');
71removeButton.onclick = () => loadingContainer.remove();
7273imageFooter.appendChild(modelElement);
74imageFooter.appendChild(removeButton);
7576loadingContainer.appendChild(loadingShimmer);
77loadingContainer.appendChild(imageFooter);
78resultDiv.prepend(loadingContainer);
7987'landscape_16_9': 16 / 9
88};
89const aspectRatio = aspectRatios[imageSize] || 1; // Default to 1 if imageSize is not found
90const containerWidth = loadingContainer.offsetWidth;
91loadingShimmer.style.height = `${containerWidth / aspectRatio}px`;
97const guidanceScale = document.getElementById('guidance_scale')?.value;
98const seed = document.getElementById('seed')?.value;
99const numImages = document.getElementById('num_images')?.value;
100const enableSafetyChecker = document.getElementById('enable_safety_checker')?.checked;
101const syncMode = document.getElementById('sync_mode')?.checked;
108prompt,
109negative_prompt: negativePrompt || undefined,
110image_size: imageSize,
111num_inference_steps: numInferenceSteps ? parseInt(numInferenceSteps) : undefined,
112guidance_scale: guidanceScale ? parseFloat(guidanceScale) : undefined,
113seed: seed ? parseInt(seed) : undefined,
114num_images: numImages ? parseInt(numImages) : undefined,
115enable_safety_checker: enableSafetyChecker !== undefined ? enableSafetyChecker : undefined,
116sync_mode: syncMode !== undefined ? syncMode : undefined,
119};
120121const response = await fetch('/generate-image', {
122method: 'POST',
123headers: {
128129const data = await response.json();
130handleImageResponse(data, imageSize, model);
131}
132133function handleImageResponse(data, imageSize, model) {
134const resultDiv = document.getElementById('result');
135136if (data.imageUrls) {
137data.imageUrls.forEach((imageUrl, index) => {
138const imgElement = new Image();
139imgElement.src = imageUrl;
140imgElement.alt = `Generated Image ${index + 1}`;
141imgElement.style.display = 'none';
142147loadingShimmer.remove();
148imgElement.style.display = 'block';
149loadingContainer.insertBefore(imgElement, loadingContainer.querySelector('.image-footer'));
150};
151173updateForm();
174const modelElement = document.getElementById('model');
175const formElement = document.getElementById('imageForm');
176const resetButton = document.getElementById('resetButton');
177
3Outputs:
4```text
5ImageMagick 7.1.1-30 Q8 x86_64 dd459b01f:20240407 https://imagemagick.org
6Delegates: freetype heic jng jp2 jpeg jxl lcms lqr openexr png raw tiff webp xml zlib
7Features: Cipher