• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Print

Scheduled Pinned Locked Moved Unsolved Requests
11 Posts 2 Posters 2.1k Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    Alexandre-Venditti69
    last edited by sdetweil Jan 6, 2023, 2:43 PM Jan 6, 2023, 2:01 PM

    Bonjour à tous, je cherche a étoffer un modules en y ajoutant une petite fonction en plus. Module : EXT-Selfies by @bugsounet. Je suis nouveau dans l’environnement de la programation et j’aurai besoin de quelques tips.
    Mon but : avoir une option, impression selfie
    J’ai énormément regarder de scripts sur cups, ipp, node.lp… et j’aimerais avoir vos conseils afin de savoir quelle serait la meilleure option ?
    Créer un module, ajouter un script au modules? Comprendre la syntaxe d’un script ipp afin d’avoir le payload de l’image envoyé à mon imprimante.?
    Tout renseignement ou aide est bonne a prendre.
    Merci pour votre aide et conseils, en vous souhaitant une très bonne année 2023.
    Informatiquement ✌🏼

    adding english (sdetweil)

    Hello everyone, I am looking to expand a module by adding a small additional function. Module: EXT-Selfies by @bugsounet. I am new to the programming environment and I will need some tips.
    My goal: to have an option, selfie printing
    I have looked at a lot of scripts on cups, ipp, node.lp… and I would like your advice on what would be the best option?
    Create a module, add a script to the modules? Understand the syntax of an ipp script in order to have the payload of the image sent to my printer.?
    Any information or help is welcome.
    Thank you for your help and advice, wishing you a very happy new year 2023.
    IT

    S 1 Reply Last reply Jan 6, 2023, 2:47 PM Reply Quote 0
    • S Offline
      sdetweil @Alexandre-Venditti69
      last edited by Jan 6, 2023, 2:47 PM

      @Alexandre-Venditti69 i do not know the answer, don’t use the EXT* modules…

      i think if you use that, then u would have to add code to that to get to the image…

      i did a quick google search for “print image from browser”
      https://stackoverflow.com/questions/52885693/how-to-print-image-from-browser-using-javascript

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      A 2 Replies Last reply Jan 6, 2023, 4:50 PM Reply Quote 0
      • A Offline
        Alexandre-Venditti69 @sdetweil
        last edited by Jan 6, 2023, 4:50 PM

        @sdetweil great thank so much, I’ve never ser this
        very interesting and complete documentation. my first difficulty in all these docs is that the file is always referred to by exact path (ex: /home/pi/img.jpg) and in our EXT module, the image is sent as payload data. how to recover this variable in the print.js script I participated with bugsounet in the writing of the module (especially spectator to understand how it works), I would have liked to make my first pull request, hear the thunder of the printer at the print notification . If a developper interrsting to write this modules with me, or maybe sale me this.

        S 1 Reply Last reply Jan 6, 2023, 5:00 PM Reply Quote 0
        • S Offline
          sdetweil @Alexandre-Venditti69
          last edited by sdetweil Jan 6, 2023, 5:06 PM Jan 6, 2023, 5:00 PM

          @Alexandre-Venditti69 well you put the image on the screen by using a url ,

          <img src="url...",
          

          so there u have the url u need to use to print

          u may have to extract it again from the html content at the time of the print request,
          but u can use the dhtml API calls to get it, or jQuery

          if u add a known ID= to the img tag

          document.getElementById(…)
          then u can get the value of the src=

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          A 2 Replies Last reply Jan 6, 2023, 5:27 PM Reply Quote 0
          • A Offline
            Alexandre-Venditti69 @sdetweil
            last edited by Jan 6, 2023, 5:03 PM

            @sdetweil i think if you use that, then u would have to add code to that to get to the image…
            Of course, bugsounet told me i ve have to add console.log(payload) on the notification.
            i ve start to write a new fonction in Ext-Selfies.js, and his node_helper.
            texte du lien this exemple script print on défaut printer , but how i can writte it to resolve the payload

            S 1 Reply Last reply Jan 6, 2023, 5:05 PM Reply Quote 0
            • S Offline
              sdetweil @Alexandre-Venditti69
              last edited by sdetweil Jan 6, 2023, 5:05 PM Jan 6, 2023, 5:05 PM

              @Alexandre-Venditti69 console.log(notification)
              will dump out the structure of the notification object so u might find the url there

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              A 1 Reply Last reply Jan 6, 2023, 5:36 PM Reply Quote 0
              • A Offline
                Alexandre-Venditti69 @sdetweil
                last edited by sdetweil Jan 7, 2023, 1:02 PM Jan 6, 2023, 5:27 PM

                @sdetweil

                showLastPhoto: function(result, sendResult = true, showLastOnly = false) {
                    var autoValidate = showLastOnly ? true : result.options.autoValidate
                    this.IsShooting = true
                    var con = document.querySelector("#EXT-SELFIES")
                    con.classList.add("shown")
                    var rd = document.querySelector("#EXT-SELFIES .result")
                    rd.style.backgroundImage = `url(modules/EXT-Selfies/photos/${result.uri})`
                    rd.classList.add("shown")
                    if (autoValidate) {
                      if (this.config.usePreview) {
                        var preview = document.querySelector("#EXT-SELFIES .preview")
                        preview.classList.remove("shown")
                      }
                      setTimeout(()=>{
                        this.lastPhoto = result
                        if (sendResult) this.sendNotification("EXT_SELFIES-RESULT", result)
                        this.closeDisplayer()
                      }, this.config.resultDuration)
                    }
                  },
                
                  validateSelfie: function(result) {
                    var preview = document.querySelector("#EXT-SELFIES .preview")
                    preview.classList.remove("shown")
                    var pannel = document.getElementById("EXT-SELFIES-PANNEL")
                    pannel.classList.add("shown")
                
                    var sendIcon = document.getElementById("EXT-SELFIES-SEND")
                    sendIcon.onclick = ()=> {
                      this.lastPhoto = result    // Sauvegarde le selfie en local
                      this.sendNotification("EXT_SELFIES-RESULT", result) // Envoi la notif pour EXT-SSender
                      this.closeDisplayer()
                    }
                

                Dans cette partie, j’ai rajouté à SendIcon :

                this.sendSocketNotification("printResult", payload)
                
                Mon node helper reçoit cette notification et exécutera printResult  function (payload) {}
                

                Est ce un bon début ?

                S 1 Reply Last reply Jan 7, 2023, 1:07 PM Reply Quote 0
                • A Offline
                  Alexandre-Venditti69 @sdetweil
                  last edited by Jan 6, 2023, 5:36 PM

                  @sdetweil thanks for your intention 🙏🏼

                  1 Reply Last reply Reply Quote 0
                  • A Offline
                    Alexandre-Venditti69 @sdetweil
                    last edited by Jan 6, 2023, 8:52 PM

                    @sdetweil I read the print.js library, it is of substantial size, does such a volume remain “compatible” with a simple raspberry?

                    S 1 Reply Last reply Jan 6, 2023, 8:54 PM Reply Quote 0
                    • S Offline
                      sdetweil @Alexandre-Venditti69
                      last edited by Jan 6, 2023, 8:54 PM

                      @Alexandre-Venditti69 no clue… raspberry pi 3 has 1 gig or memory and pi4 can have up to 8gig.

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      1 Reply Last reply Reply Quote 0
                      • 1
                      • 2
                      • 1 / 2
                      1 / 2
                      • First post
                        5/11
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy