-13

So I asked what I thought was a pretty basic and straightforward question about how to do something in Python. That led to someone(s) closing my question saying it was a "how do I do this?" qeustion which implied I wanted the community to write code for me.

Ok - fair point so I updated the question to reflect I was just looking for a general approach or suggestion for Python libraries, That then got rejected saying I was now asking double questions in 1 post. Ok - so I fine tuned it again to be super specific and even started to get some responses before it was closed a 3rd time. This time because I was "seeking recommendations for books, tools, software libraries"

Really? Ok, so I removed the request for "what libraries in Python can do this.." and asked more generally. That then got closed a 4th time.

I re-read all the Stack Overflow guidance on questions and the overall general principles of the community:

  • a specific programming problem, or
    • a software algorithm, or
    • software tools commonly used by programmers; and is
    • a practical, answerable problem that is unique to software development

Is my question inappropriate for Stack Overflow and I don't fully appreciate the forum vs. what I'm used to on other forums?

Here is my question Python library to compress image data size?

I’m using a usb camera to capture a single image using OpenCV on a raspberryPI. I need to send that image over a socket to a server over wifi to run it through a neural network and do some image processing. I need to minimize the wifi network latency. What is a method to compress the image data within python?

7
  • 2
    i'm actually kinda surprised it was reopened 4 times. Not because the question didn't deserve it, but because how often reopening is portrayed as a rare occurance.
    – Kevin B
    Commented Jul 14, 2022 at 17:38
  • 1
    Ah, it wasn't. It was closed once... did you reask it over and over? it's very unlikely someone has a vendetta against you specifically on SO.
    – Kevin B
    Commented Jul 14, 2022 at 17:39
  • 8
    Reposting your question over and over again is rarely going to be well received. There is an edit feature you can use to improve your questions.
    – Thom A
    Commented Jul 14, 2022 at 17:41
  • 3
    Still a library rec. question, see title in rev. 3. Though even if you fix that it's still tickling my "too broad" senses. Lossy compression? Lossless? Throughput requirements? Latency requirements? Biased toward compression speed? Decompression speed?
    – genpfault
    Commented Jul 14, 2022 at 17:47
  • 1
    If you believe someone has a vendetta, flagging their comments is the way to deal with this. Moderators can then decide your case. However, Your question is definitely not worthy of reopening(The answers below explain why). Even if someone has a vendetta, if your question is good, no one can unilaterally decide to close it(except where it is a duplicate and the voter has special privileges, which is not the case here). It requires a minimum of three community members to agree to vote to close.
    – TheMaster
    Commented Jul 14, 2022 at 18:09
  • 4
    You're literally asking for a library in the title, I'm not sure what's unclear about why it got closed for that reason. Commented Jul 14, 2022 at 18:17
  • the two questions in question (heh) are stackoverflow.com/questions/72965754/… and stackoverflow.com/questions/72945923/… Commented Jul 14, 2022 at 19:59

2 Answers 2

13

I’m using a usb camera to capture a single image using OpenCV on a raspberryPI. I need to send that image over a socket to a server over wifi to run it through a neural network and do some image processing. I need to minimize the wifi network latency. What is a method to compress the image data within python?

The reason you want to compress the image data only matters if you have a specific reason to believe that there is a specific kind of compression that would give better results in this specific situation - i.e., because you can know certain things about the data that a compression algorithm can exploit to get better results.

In this case, the source of the image is... image capture from a camera. The image could look like anything, so we get no additional information. Everything else is just saying "I want to compress the image because it will solve or mitigate other technical problems" - it is redundant. So the question is really:

What is a method to compress the image data within python?

Or more succinctly put,

How can I compress an image in Python?

This is clearly far too broad. First off, yes, generally one would use a library for this task - compression algorithms are a lot of work and you really don't want to try to write one by hand; they also involve a lot of theory.

Of course, you didn't ask for a library, and might reasonably not have expected to need or want one. But the task is too broad - the existence of those libraries demonstrates it. A single sentence query offers countless approaches to the task (compression algorithms), each of which expands into a huge volume of code, backed by considerable theoretical understanding (information theory).

(Edit: Your title reads "Python library to compress image data size?", and has been the same the whole time. That is pretty clearly asking for a library.)

On top of that, the actual requirements are not clear. Many compression algorithms - especially for images, video, audio and other media - are "lossy": the reconstructed output cannot reproduce the original exactly, but is similar enough to pass a superficial human examination. Before using compression, you have to decide whether this is acceptable, and the extent to which it is acceptable. Similarly, "within Python" is not really that well specified. One possible approach to the problem is to find an image editor that has a command-line interface, and then use os.system or other such tools to launch that other program, and have it apply and save the changes.

Finally, you are expected to look for solutions before posting. It is as simple as putting something like python compress image into a search engine.


It has also been pointed out to me that this isn't the first attempt to ask the same question. The changes from your first attempt are not substantive, and don't demonstrate the sort of research I mentioned.

  • If you want to use a library, it is your responsibility to look for one, figure out its basic use, and then perhaps ask a specific question if/when you run into problems with actual code trying to use it.

  • If you want to get an already-compressed image from the webcam, it is your responsibility to check the documentation for the interface to the webcam, first.

12

I don't see a way to - in good faith - reopen this question for topicality.

Putting aside the original request of asking us to look for a library to accomplish this, you're still asking quite a lot of us here.

For context, this is the revision I'm looking at (most recent as of answering).

I’m using a usb camera to capture a single image using OpenCV on a raspberryPI. I need to send that image over a socket to a server over wifi to run it through a neural network and do some image processing. I need to minimize the wifi network latency.

What is a method to compress the image data within python?

So what we know:

  • You're using Python and OpenCV
  • You've got a Raspberry Pi
  • You've got a webcam
  • You want to get data from webcam to Pi via Python, where it's sent is moderately inconsequential

What we don't have:

  • What you've tried
  • Where you're stuck
  • What you're using to accomplish the transmission of data via Python

If you've got a little bit more meat - that is, you showcase what it is you've actually done on this effort - then perhaps that'd be more impetus to reopen it. The state it's in now indicates that it shouldn't be reopened.

7
  • Regarding the library - are you kind folks telling me that asking about open source libraries or libraries that are part of Python (or any language) is off limits for Stack Overflow? I believe the "don't ask about commercial tools, etc." is more about opening the door around recommendations for commercial paid software. I'm sure we all talk about libraries that are available in programming languages all the time.
    – user17535004
    Commented Jul 14, 2022 at 19:52
  • In my initial edit i clearly stated "what python library can i use to compress an image" - not sure thats broad at all and i got 2 very good answers that sent me on my way. I have the feeling that by my editing my post it pissed someone off and they kept finding ways to close all my subsequent edits. The lesson here is that Stack Overflow is only limited to asking specific questions about fixing a coding issue or asking a very specific coding question. Many times architects, designers, and programmers are looking for patterns, approaches, and some pointers to how to solve a problem.
    – user17535004
    Commented Jul 14, 2022 at 19:53
  • 4
    no, you can ask about libraries, you just can't ask people to do your googling for you ("recommend me libraries"). often you still get recommendations, if you show that you at least tried to do your homework... and that question doesn't contain any evidence that you worked the problem. this site works because askers respect and value the time and effort given freely by answerers. part of that is not making answerers make up for your lack of demonstrated least effort. Commented Jul 14, 2022 at 19:55
  • 5
    @DaveInPA: No one here has a problem with you asking about libraries. The problem is that you're asking for libraries to solve your problem. Even if we set that aside, you're still asking us to help solve your problem in such a way that makes it too difficult to define a "correct" answer. Minimizing WiFi latency depends on a lot of factors that aren't related to the code you write. But back to the code - "how do I do this" is such an open-ended question that we can't really begin to answer it without a significant time investment from volunteers, which is why it's too broad.
    – Makoto
    Commented Jul 14, 2022 at 20:19
  • Yea now my closed question is being deleted. Seems people really don’t like when you try to edit your closed question to improve it. Still haven’t heard anyone justify what’s wrong with “is there a library that does something…”. Of course I did my Google searches and didn’t really see anything for my use case. I’m not compressing a file I’m compressing a variable in memory. Asking people how they do a similar thing is what forums are all about. At this point I think someone just didn’t like my fixing the question and had it our for it.
    – user17535004
    Commented Jul 15, 2022 at 11:46
  • 2
    @DaveInPA Makoto very clearly just explained what the issue with these kind of questions are. Please don't think this is someone not liking you, you just posted a question against the guidelines, that's all. It's probably happened to every person here at some point, so don't take it personally, just use it as an opportunity to learn how to ask a better question. (Also SO isn't a forum.)
    – user438383
    Commented Jul 15, 2022 at 11:48
  • I just read the answer to “ why-is-can-someone-help-me-not-an-actual-question?” And it nicely explains. STack O is for specific programming questions. It’s not a forum to discuss approaches to solving problems with programming like many other forums where you state a goal and get pointers. I will say whoever closed my question because I asked which library does something applied the wrong reason code for that. The answer I got “pillow library” was what I needed after all. But it was a program design thing and I guess that’s not what stack O is for.
    – user17535004
    Commented Jul 15, 2022 at 11:59