question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use Image correctly

See original GitHub issue

If reference the image in react

import testPng from './static/text.png'

<Image src={testPng}/>

console:

QPixmap::scaled: Pixmap is a null pixmap

Okay it doesn’t work

If I use resolve to reference the image

const imageUrl = `${path.resolve(__dirname, `./static/text.png`)}`;

<Image src={imageUrl}/>

When I was debugging it was successful

But when I pack:

webpack -p && nodegui-packer --pack ./dist

the image has not been webpacked and is not packed into dist

Image doesn’t show up after I open the app

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:24 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
a7ulcommented, Mar 2, 2020

Alright! I manage to fix this issue in MacOS @Grewer and @Solant This will be fixed in the next packer release.

But if you would like to fix it in your current setup.

After npx nodegui-packer --init MyApp

Change the contents of deploy/darwin/MyApp.app/Contents/MacOs/qode.json to

{
  "distPath": "../Resources/"
}

Add a new file at deploy/darwin/MyApp.app/Contents/Resources/index.js with the contents

const path = require("path");
// Fix so that macos resources are found correctly
// since webpack will bundle them such that the expected path is /dist from cwd
process.chdir(path.resolve(path.dirname(process.execPath), "..", "Resources"));
// Now start loading the actual bundle
require("./dist");

Now do npx nodegui-packer --pack ./dist

And the assets paths should be resolved correctly!

0reactions
a7ulcommented, Feb 17, 2020

Hi @Solant and @Grewer This is because the current working directory for macos is something different. I am currently working on Qode v2.0 which might need a bit of changes in the packer as well. So I ll fix it up in packer alongside it. ETA: this weekend for now. But lets see if I can fix it before that. Thanks for looking into this @Solant

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Ultimate Guide For Using Images On Your Website
Choosing the right images for your website is important. This guide shows you how to best use images for your website.
Read more >
How to Use Images Effectively in Websites - WebFX
Use Images with Purpose · Use Photos of Real People · Point Out the Obvious · Use Images to Illustrate Concepts · Optimize...
Read more >
How to Resize an Image Correctly | The TechSmith Blog
Use photo editing software to resize your image; Avoid stretching or distorting your images by locking the aspect ratio before making adjustments. Start...
Read more >
The Essential Guide to Using Images Legally Online
Image use can be tricky. Learn EXACTLY how to legally use images online, how to interpret licenses, and find copyright-free images.
Read more >
Formatting your images for display on the web
Your image's color mode or color profile might not be formatted correctly. Review our image requirements to confirm you're using the correct ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found